Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Remote MySQL connections  (Read 2381 times)

0 Members and 1 Guest are viewing this topic.

Vinil

  • Guest
Remote MySQL connections
« on: November 20, 2013, 06:09:49 pm »
In some cases you may need to enable non-localhost connections to MySQL database. It’s easy to do on any Linux-based servers.

1). Connect to your server via SSH as root.

2). Log into MySQL as root and enter the following command:

Code: [Select]
GRANT ALL PRIVILEGES ON database.* TO user@'IP' IDENTIFIED BY 'password';

where,
* database is replaced by the name of the database you’d like to allow access to. Using * will allow access to all databases.
* user is replaced by the username you want to allow.
* IP is replaced by the actual IP to connect from. Using % will allow access from all IPs.
* password is replaced by the desired password.


3). Apply changes you’ve made with the following command:

Quote
FLUSH PRIVILEGES;

4). You might also need to allow connections to port 3306 (standard MySQL port) from a remote IP. Run the following command in shell:

Code: [Select]
iptables -I INPUT -s IP -p tcp --dport 3306 -j ACCEPT
Don’t forget to replace IP with the actual IP you want to allow MySQL connections from.