Page 1 of 1

Problem with remote access to the MYSQL

Posted: Thu Nov 03, 2016 6:52 am
by maniek015
Hello,
I have a trouble to remote access to the MySQL.
I have a two server with the VestaCP. In the on of this server in my script i must have remote access to the database (MYSQL)

I tried connected to the host by the IP, by the domain but this still don't work.

I must to add some exceptions on the server connection to work?

The script must connect to the server number two to a database that is located on a server number one. Please help.

I have a standard config of Vesta. System is a Debian 8.6 x64

Re: Problem with remote access to the MYSQL

Posted: Thu Nov 03, 2016 7:32 am
by mehargags
you need to make sure your MySQL is listening on port 3306 and your Public IP, by default Mysql is listening to unix socket (localhost). Also ensure port 3306 is not blocked in your firewall.

Once you get it working, if possible only allow certain IP or IP range to be able to connect to MySQL on TCP port remotely. This will make it more secure.

Re: Problem with remote access to the MYSQL

Posted: Thu Nov 03, 2016 7:48 am
by maniek015
mehargags wrote:you need to make sure your MySQL is listening on port 3306 and your Public IP, by default Mysql is listening to unix socket (localhost). Also ensure port 3306 is not blocked in your firewall.

Once you get it working, if possible only allow certain IP or IP range to be able to connect to MySQL on TCP port remotely. This will make it more secure.
Thanks for the reply.
MySQL is able to connect on TCP Port 5342 and 3306. Ping to mysql server is okay

Re: Problem with remote access to the MYSQL

Posted: Thu Nov 03, 2016 9:01 am
by maniek015
In the additional.
I can't connect to the my configuration script to the database on server number one with the VestaCP. I must add anything to the connect? Host is a IP of server.

Re: Problem with remote access to the MYSQL

Posted: Thu Nov 03, 2016 10:32 am
by maniek015
I try connect by the SSH to the mySQL and i have :

root@ns325037:~# mysql -h here_is_my_ip -u database_name -p
Enter password:
ERROR 1045 (28000): Access denied for user 'here_is_username' (using password: YES)
root@ns325037:~#

In vesta CP firewall i have the accept TCP from the 3306 and 5432. I must add something new?

Re: Problem with remote access to the MYSQL

Posted: Thu Nov 03, 2016 3:28 pm
by mehargags
You don't have the user created on the host MySQL with which you are trying to connect from your guest script.

Re: Problem with remote access to the MYSQL

Posted: Fri Nov 11, 2016 8:09 pm
by hsschile
# Change MySQL root password

v-change-database-host-password mysql localhost root New*Password

# Run MySQL

mysql -uroot -pNew*Password

# Give root user remote access privileges from any host

GRANT ALL PRIVILEGES ON *.* to 'root'@'%' identified by 'New*Password' WITH GRANT OPTION;FLUSH PRIVILEGES;

# Exit from MySQL

quit

# Restart MySQL

service mysql restart

# Try again to remote connect to your MySQL server