Can't connect to remote mysql database server - mysql

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:
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
And i have this in my my.cnf
Why having this error?
Anyone please help.

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

Related

This localhost page can’t be found :Phpmyadmin

after resolving the issue of Apache and Mysql, suddenly I am facing the issue as Localhost not found.
No webpage was found for the web address: http://localhost/phpmyadmin
Issue I have resolved for MYSQL is :
# The following options will be passed to all MySQL clients
[client]
# password = your_password
#port = 3306
port =8111
socket = "C:/xampp/mysql/mysql.sock"
Here follows entries for some specific programs
# The MySQL server
[mysqld]
#port= 3306
port = 8111
socket = "C:/xampp/mysql/mysql.sock"
basedir = "C:/xampp/mysql"
tmpdir = "C:/xampp/tmp"
datadir = "C:/xampp/mysql/data"
I have port to 8111 in both the cases as this was the only option which helped me out while running MYSQL.
Any help?
The problem may be related with Your Localhost Port. rather than typing http://localhost/phpmyadmin type like 'http://localhost:PortNumber/phpmyadmin'.
check Your port Number at 'httpd.conf' file. these are the basic
Listen 'Your Port number like 80 or else
ServerName localhost:'Your Port number like 80 or else

MySQL stopping and socket file dissapearing

I am having problems launching MySQL on my local machine. Every time I try to launch the instance I get an:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")
For creating the required file I followed this solution changing the directory /var/lib/... to /var/run/... since it is how my configuration is set. The weird thing is that when I follow the steps described the process is launched and I can access to my database, but after a while it suddenly stops and the files (mysqld.sock and mysqld.pid) dissappear. How can this be possible? How can avoid it from happening?
The settings on my 50-server.cnf of my mariadb are:
#
# * 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 = localhost

Connect to remote mysql server from ubuntu fails

I'm using AWS server (ubuntu) for backup my remote mysql db, using mysqldump command.
Since I changed the db password, I cannot connect anymore remotely from the machine using /etc/mysql/my.cnf configuration file.
When I'm using the command
mysql -u root -h 1.1.1.1 -p 123456
It's connects successfully, but when I'm trying to connect by using the mysql configuration file /my.cnf by typing just
mysql
I gets the error message :
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I restarted the db server (I don't need mysql service running on aws because I connected remotely)
I don't want to connect through any socket
my.cnf file content:
[client]
port = 3306
host = 1.1.1.1
user = root
password = 123456
[mysqld]
user = mysql
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
bind-address = 1.1.1.1
I don't know what have changed, except from the password, I didn't change anything neither in the db itself and in the config file, so I have no idea why it stopped working.
Add in the my.cnf the line protocol=tcp
[client]
port = 3306
host = 1.1.1.1
user = root
password = 12345
protocol = tcp
That force MySQL to use TCP and not the socket connection

MySQL Failed to load adter Remote Connectivity Configuration

I am using Amazon Cloud to deploy my web services. However, this requires a MySQL instance and I already installed it. In order to allow remote connectivity to MySQL database, I followed the below sequence as elaborated in MySQL documentation and even in the below thread.
Edit my.cnf file to change the following.
[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 = <server ip OR 0.0.0.0>
The same solutions discussed in detail, following posts.
Remote Connections Mysql Ubuntu
http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html
However, as soon as I edited the my.cnf file as mentioned, the MySQL server failed to restart. I tried my best to recover this, it's failing instead.
Could anyone help me to identify and resolve the issue, would be a great help.
Verify that the MySQL server isn't running.
Try setting the bind-address to 0.0.0.0
bind-address = 0.0.0.0
Verify that the files are deleted
/var/run/mysqld/mysqld.sock
/var/run/mysqld/mysqld.pid

MYSQL connecting from outside network

i am having trouble connecting to mysql from a outside network. If i were to connect it locally, it can be done. Assuming i'm a host, what should i do?
You need to set up port forwarding in your router on port 3306 to your local IP port 3306. You'll need to grant rights to a user to allow access from external IP.
For example:
CREATE DATABASE Test;
GRANT ALL ON Test.* TO remoteUser#'10.11.12.100' IDENTIFIED BY 'PASSWORD123';
Or all tables:
GRANT ALL PRIVILEGES ON *.* to remoteUser#10.11.12.100 IDENTIFIED BY "PASSWORD123";
If that don't work check your MySQL server settings, Example /etc/mysql/my.cnf (Debian)
Settings file:
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306 - CHECK THAT PORT IS CORRECT
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/English
bind-address = 1.1.1.1 CHECK THAT IP IS CORRECT
skip-networking = DELETE OR # FRONT OF IT
Port forward your router on port 3306. This is the default port for mysql. Make sure you have the same port open on your server. Make sure your ISP (Internet Service Provider) allows traffic on this port. I would suggest using something like MySQL Workbench http://www.mysql.com/products/workbench/ to manage your database if you don't already.