7

I installed mysql server on my machine and I could connect using MySqlWorkbench as localhost (port:3306). But when I change the localhost to my machine name it is not working. I need to access the database from another machine where my webserver resides, so accessing as localhost would not help. What could be wrong?

PS. I could access local apache as localhost:8080 as well as machinename:8080. I was expecting similar behavior with MySql

1
  • 1) check your firewall and make sure it allows traffic inbound on 3306. 2) run (as root) netstat -ntlup | grep 3306 and make note of the 'local Address'. is it 0.0.0.0:3306 or 127.0.x.y:3306 (x and y can be any number < 255). if its 127.0.x.y, follow these instructions to make it listen for external connections (0.0.0.0:3306). howtogeek.com/howto/mysql/switch-mysql-to-listen-on-tcp Commented Jan 17, 2014 at 3:48

1 Answer 1

4

The computers that are allowed to connect to a mysql server are defined in /etc/my.cnf

You will need to edit the file to allow connection from all computers

[mysqld]
bind-address = localhost #Change from localhost to '0.0.0.0' (all zeros) 
skip-networking   #Comment out this line if it exits
enable-named-pipe #Comment out this line if it exists

Be careful, once you have changed the bind-address from localhost to 0.0.0.0, mysql will allow connections from anywhere. You should lock down your firewall to only allow specific machines in.

You also may need to modify the database to allow remote connections. If your ip of the remote machine is 192.168.1.100

 GRANT ALL PRIVILEGES ON *.* TO db_user @'192.168.1.100' IDENTIFIED BY 'db_passwd';

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.