How to enable remote mysql access in centos?

My apache runs on port 8113 instead of 80 .

I want to remotely access my mysql database. I have tried the following steps.

 Bind-address XXX.XX.XX.XXX in /etc/my.cnf Create Database and run the command GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'IP' IDENTIFIED BY 'PASSWORD'; 

But cannot connect. I am using heidi sql to connect.

+11
mysql centos
source share
2 answers

so do the following edit my.cnf:

 [mysqld] user = mysql pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock port = 3306 basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp language = /usr/share/mysql/English bind-address = xxx.xxx.xxx.xxx # skip-networking 

after editing click service mysqld restart

log into MySQL and click this query:

GRANT ALL ON foo.* TO bar@'xxx.xxx.xxx.xxx' IDENTIFIED BY 'PASSWORD';

So, make sure your iptables allows connection to 3306 if the following is not set:

iptables -A INPUT -i lo -p tcp --dport 3306 -j ACCEPT

iptables -A OUTPUT -p tcp --sport 3306 -j ACCEPT

+10
source share

Bind-address XXX.XX.XX.XXX at /etc/my.cnf

comment line:

network pass

or

skip external locking

after editing hit service mysqld restart

log into mysql and click this query:

 GRANT ALL PRIVILEGES ON dbname.* TO 'username'@'%' IDENTIFIED BY 'password'; FLUSH PRIVILEGES; quit; 

add firewall rule:

 iptables -I INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT 
+12
source share

All Articles