sam
sam

Reputation: 31

unable to access MySQL server remotely on centOS

I have centos 6.5 on which MySQL 5.6.21 is running, i am trying to access this MySQL server from my Linux 14.0.4 LTS server but every time it show ERROR 2003 (HY000): Can't connect to MySQL server on '192.192.4.86' (113).

I am able to access centOS using putty and winscp from my windows machine but not able to connect centOS mysql server from any other operating system.

I did following things.

skip-networking is also commented. GRANT ALL PRIVILEGES ON . TO 'root'@'192.192.4.222' IDENTIFIED BY 'root'; GRANT ALL PRIVILEGES ON . TO 'root'@'127.0.0.1' IDENTIFIED BY 'root'; GRANT ALL PRIVILEGES ON . TO 'root'@'localhost' IDENTIFIED BY 'root';

Add following things in iptables

-A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT
-A INPUT -i eth0 -s 192.192.4.222 -p tcp --destination-port 3306 -j ACCEPT
-A INPUT -s 192.192.4.85 -m tcp -p tcp --dport 3306 -j ACCEPT

port 3306 is also in listing mode i already checked.

netstat -nat |grep 3306

tcp  0  0 :::3306  :::*  LISTEN

but not able to access centos MySQL Server remotely.

If any one know where I am wrong or something missing please let me know.

Thanks in advance.

Upvotes: 2

Views: 10429

Answers (2)

Kent Aguilar
Kent Aguilar

Reputation: 5368

You could try this out.

Configuration:
By default MySQL will listen for connections only from the local host. To enable remote connections like the one used by mysqlworkbench you will need to modify your /etc/my.cnf and change

bind-address 127.0.0.1

to

bind-address 0.0.0.0

or simply comment out the line completely. Once this is done, restart MySQL with the command.

service mysql restart

MySQL Privilege:
Or, like the ones mentioned on initial answers, you could grant privilege under MySQL itself. Like so,

grant all privileges on *.* to 'root'@'your-public-ip' identified by 'your-password'

Upvotes: 2

Swapnil Gangrade
Swapnil Gangrade

Reputation: 462

login to your mysql with root username and root password

mysql -u root -proot

Run Below commands to run mysql as remote host

GRANT ALL ON *.* TO mysqluser@'localhost' IDENTIFIED BY 'mysqluser';

GRANT ALL PRIVILEGES ON *.* TO 'mysqluser'@'localhost' WITH GRANT OPTION;

CREATE USER 'mysqluser'@'%' IDENTIFIED BY 'mysqluser';

GRANT ALL PRIVILEGES ON *.* TO 'mysqluser'@'%' WITH GRANT OPTION;

Now Check you are able to login to hostname with username and password

mysql -h yourhostname -u mysqluser -pmysqluser

Upvotes: 1

Related Questions