Failed to connect to remote mysql server in digital ocean

I am trying to connect to a remote MySQL 5.7 server installed on Ubuntu 16.04 from my workstation.

Here is the error I am getting (using Navicat to connect).

enter image description here

To do this, I have completed the following steps.

1) GRANT ALL ON database_name.* TO user@xx.xxx.xx.xx IDENTIFIED BY 'your_password';

2) flush privileges;

3) sudo /etc/init.d/mysql restart

Some forums recommend that the comment line begin with "bind-address" on my.cnfwhich is located at /etc/mysql/my.cnf. The problem is that in my installation there is no such line.

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

I also tried opening the ports in the firewall using the following commands.

sudo ufw allow 3306/tcp
sudo service ufw restart

But still the problem is with the same problem.

: MySQL , bind-address=0.0.0.0 my.cnf. MySQL .

demo@ubuntu:~$ sudo /etc/init.d/mysql restart
[....] Restarting mysql (via systemctl): mysql.serviceJob for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
 failed!
demo@ubuntu:~$
+4
2

:

, : ubuntu /var/log/mysql /etc/mysql/my.cnf.

-, mysql , , # . , , -. .

[mysqld]
# bind-address=0.0.0.0

mysql telnet ip . , . ex -

telnet xx.xx.xx.xx 3306

, mysql, % , , . ex -

GRANT ALL ON database_name.* TO 'user'@'%' IDENTIFIED BY 'your_password';

, .

+1

bind-address=0.0.0.0 /etc/mysql/my.cnf, , 2 :

[]

- = 0.0.0.0

"", , , .

0

Source: https://habr.com/ru/post/1670898/


All Articles