• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
The Electric Toolbox Blog

The Electric Toolbox Blog

Linux, Apache, Nginx, MySQL, Javascript and PHP articles

  • Applications
  • FCKEditor
  • Apache
  • Windows
  • Contact Us
Home / How to enable remote access to a MySQL database server

How to enable remote access to a MySQL database server

MySQL is often configured to be accessible from the local host only. Recently I moved all my websites from a CentOS box to a Debian one and needed to be able to connect to the MySQL server on the new box from the old one, but was not able to. This post looks at how to enable MySQL to be accessible from remote servers.

The MySQL configuration file is at /etc/mysql/my.cnf on Debian and similar distros and /etc/my.cnf on CentOS, Red Hat Enterprise Linux and similar. It contains a bind-address setting which is often set as follows by default:

bind-address = 127.0.0.1

This binds the MySQL deamon to 127.0.0.1 which is the local machine and means it will not be able to be accessed from other machines, whether or not the firewall and/or privilege grant options allow it.

To allow it to be accessible from any host, comment the line out as shown in the following example and then restart MySQL:

#bind-address = 127.0.0.1

Note that you could set the IP address to that of the server but it will mean all connections to the MySQL server must be via that IP address as it is not currently possible to bind MySQL to more than one IP address. It’s simply easier to comment the line out.

You’ll still need to enable access to the MySQL server through the firewall from the remote server(s) and add/modify the appropriate permissions to the privileges tables and then you’ll be good to go.

Check Out These Related posts:

  1. Location of MySQL’s my.cnf file
  2. Nslookup: command not found error on CentOS 5
  3. MySQL utility commands
  4. Scp command

Filed Under: MySql

Primary Sidebar

Categories

  • Apache
  • Applications
  • Article
  • Case Studies
  • Email Servers
  • FCKEditor
  • HTML And CSS
  • Javascript
  • Linux/Unix/BSD
  • Microsoft SQL Server
  • Miscellaneous Postings
  • MySql
  • Networking
  • Nginx Web Server
  • Offsite Articles
  • OSX
  • PHP
  • Quick Tips
  • RFC – Request for Comments
  • SilverStripe
  • VMWare
  • VPN
  • Windows
  • WordPress

Recent Posts

  • Vim Show Line Numbers
  • Add User To Group Linux
  • Chmod 777 Tutorial
  • How to Copy Directory Linux
  • Linux create user

Copyright © 2021. ElectricToolBox. All Rights Reserved.

  • Contact Us
  • Copyright Info
  • Privacy Policy
  • Sitemap