I have problem to connect remote LAN MYSQL. While try following commands it shows the following error.
$ mysql -u root -h 192.168.1.15 -p
mysql>
Comment the line below in file /etc/mysql/my.cnf
# bind-address = 127.0.0.1
And add (any)host permission to login(maybe root) on mysql server.
Hard way: you need insert in mysql.host table...
Easy way: use MySQL Administrator->User Administration->Choose user->(Right mouse click)Add host->Select "Any host"
Finally restart server:
/etc/init.d/mysql restart
PS: Default install aptitude
mysql version: MySQL 5.1.57-1~dotdeb.0
Linux Debian 6 Squeeze
Just thought I'd throw in another suggestion here...
Some MySQL GUI tools (Sequel Pro for Mac and EMS SQL Manager for Windows) allow MySQL connections through SSH tunnelling. This means you don't have to grant extra privileges. I have found this to be the fastest way of getting remote access to MySQL databases that I administer.
Find the following line: [mysqld]
and make sure line skip-networking
is commented (or remove line) and add following line:
bind-address=YOUR-SERVER-IP
For example, if your MySQL server IP is 66.166.170.28 then entire block should be look like as follows:
[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 = 66.166.170.28
# skip-networking
.......
Where
Start the MySQL monitor with this command: mysql
or /usr/local/mysql/bin/mysql
. Your shell prompt should now look like this: mysql>
. Run this command:
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' IDENTIFIED BY "PASSWORD";
Where:
You now must flush MySQL's privileges. Run this command:
FLUSH PRIVILEGES;
Run this command to exit MySQL:
exit;
/etc/init.d/mysqld restart
or
/etc/init.d/mysql restart
depending on what linux distro is your server currently running.
As above, getting rid of "skip-networking" in my.cnf need to be done.
However, on some configurations, that is over-ridden by SKIP="--skip-networking" in a start-up file, such as rc.mysqld. So take that out also.
Does hosts.allow permit one machine to talk to the other in any case?
And leave us not forget the actual documentation.
You should also check that your MySQL server has been configured to accept remote TCP connections.
In your MySQL configuration file (my.cnf), you need the following at least:
port = 3306 # Port MySQL listens on
bind-address = 192.168.1.15 # IP address of your server
# skip-networking # This should be commented out to enable networking
The default in some configurations is for the bind-address to be 127.0.0.1, or to skip networking completely, which means only local or unix socket connections are possible. This is for security reasons.
You can also configure the bind-address to be 0.0.0.0 which means it will bind on all IP addresses on the server.
And lastly, check your firewall configuration to allow port 3306.
GRANT ALL ON test.* TO 'root'@'192.168.1.15' IDENTIFIED BY '';