Can not setup external access to MySQL server

71 views Asked by At

I'm trying to allow external access to MySQL server. First I changed my.cnf to this (part of my.cnf): [mysqld_safe] socket = /var/run/mysqld/mysqld.sock nice = 0

[mysqld]
#
# * Basic Settings
#
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
lc-messages-dir = /usr/share/mysql
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 0.0.0.0

In /etc/hosts.allow I added: mysqld: all

Also I added user 'root'@'%', but what I have is that: I'm trying to connect from server to server using external host name:

root@******:~# mysql -h******.com -u root -p
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

But using 'localhost' all is fine: root@******:~# mysql -hlocalhost -u root -p

MySQL Server version: 5.5.43 Ubuntu 14.10 (GNU/Linux 3.16.0-23-generic x86_64)

1

There are 1 answers

0
Hitesh Mundra On

You should run the commands after creating user-

GRANT ALL ON dbname.* TO 'root'@'%' IDENTIFIED BY 'root';
FLUSH HOSTS; 
FLUSH PRIVILEGES;

if you have already run this code then there could be fire wall problem-