Dreamer XD
Dreamer XD

Reputation: 204

Can't connect to remote mysql database server

I can't figure out why i cant access a remote MySQL server in ubuntu inside a VMware. I already have the codes, and it's successfully connecting to my localhost as well as insert, delete and update of data's. But when I make a new connection string with specified IP server address it show an error:

enter image description here

I can only access the files in that server through SSH and browser (192.168.56.xxx/phpmyadmin).

Here's my code for connection string.

 Dim conn As New MySqlConnection
 conn.ConnectionString = "Server=192.168.56.xxx;port=3306;User=root;password=mypassword;Database=prodDB_vb"
 conn.Open()
 MessageBox.Show("Connection to Database has been opened.")
 cmd.Connection = conn

I already read a lot of forums about this. But dont understand what they are pointing to. Also i executed the code:

  GRANT ALL PRIVILEGES ON prodDB_vb TO 'root@*' IDENTIFIED BY 'my_password';
  FLUSH PRIVILEGE;

The only thing i know is that i cannot find the my.cnf in the server files, but already change my my.ini in my localhost's bind ip address.

  #bind-address="127.0.0.1" 

3306 is listening

enter image description here

And i have this in my my.cnf

enter image description here

Why having this error?

enter image description here Anyone please help.

Upvotes: 1

Views: 9516

Answers (1)

Amarnath Balasubramanian
Amarnath Balasubramanian

Reputation: 9460

Did you check to make sure that MySQL is actually listening on 3306? Run a netstat -tlpn and provide the results. If you don't see 3306 then its probably not.

In my.cnf you should verify that --skip-networking is commented out


[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    = 65.55.55.2
# skip-networking 

To locate your CNF file

Edited:

For example, if your MySQL server IP is 192.162.0.3 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    = 192.168.0.3
# skip-networking
....
..
....

  • bind-address : IP address to bind to.
  • skip-networking : Don’t listen for TCP/IP connections at all. All interaction with mysqld must be made via Unix sockets. This option is highly recommended for systems where only local requests are allowed. Since you need to allow remote connection this line should removed from file or put it in comment state.

Then we have to Restart mysql service to take change in effect:

/etc/init.d/mysql restart

Upvotes: 0

Related Questions