How to make mysql accept connections externally
I have a VPS and I want to make mysql DB accept connection externally (from my PC for instance). I have Debian Linux installed on the server. I checked some tutorials online and they said to comment out:
bind-address = 127.0.0.1
But this didn't seem to help! is there anything specific for VPSs? or Am I missing something else? The command that runs mysql is:
/usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --port=3306 --socket=/var/run/mysqld/mysqld.sock
The MySQL server must be configured to accept connections externally (binding to the correct network interface as appropriate), and its firewall must be configured to allow incoming connections on that port (TCP port 3306). This may or may not already be set up when you installed MySQL (see iptables if you're on *nix).
You must also account for this in the MySQL permissions as follows.
Often, when setting up your MySQL permissions, you'll set user access rights only for @'localhost'. You'll need to make sure that both the user account and its granted permissions are set for the appropriate hostname or IP address you will be connecting from. For example, you could create a new authorised user with:
GRANT ALL PRIVILEGES ON somedatabase.* TO [email protected]'somehostname' IDENTIFIED BY 'password'; FLUSH PRIVILEGES;
You have to do all of this before you can connect to that server remotely, using something like this (this example uses PHP):
mysql_connect('mysqlservername', 'someuser', 'password');
- A Linux, Apache, MySQL, PHP (LAMP) stack is a combination of open source software that is typically installed together to enable a server to host dynamic […]
- MySQL is an the most popular open-source database management system, in most of hosting company its has been bundle by LAMP(Linux, Apache, MySQL, PHP/Python/Perl) stack. Another alternative […]
- MySQL is the world’s most popular open-source database. Despite its powerful features, MySQL is simple to set up and easy to use. Below are some instructions […]