Мучаюсь уже 2ой день с этой проблемой
Есть внешний сервер с только что поставленной mysql. Действовал по
гайду. Вот такой вывод:
root@vm2016208:~# sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
root@vm2016208:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.31-0ubuntu0.20.04.1 (Ubuntu)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CREATE USER 'sammy'@'*MY_IP* ' IDENTIFIED BY 'password';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> SET GLOBAL validate_password.policy= LOW ;
Query OK, 0 rows affected (0.01 sec)
mysql> CREATE USER 'sammy'@'*MY_IP* ' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.02 sec)
mysql> GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'sammy'@'*MY_IP* ' WITH GRANT OPTION;
Query OK, 0 rows affected (0.04 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql> exit
Bye
root@vm2016208:~# sudo ufw allow from *MY_IP* to any port 3306
Rule added
root@vm2016208:~# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.31-0ubuntu0.20.04.1 (Ubuntu)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select (host, user) from mysql.user;
ERROR 1241 (21000): Operand should contain 1 column(s)
mysql> select host, user from mysql.user;
+---------------+------------------+
| host | user |
+---------------+------------------+
| *MY_IP* | sammy |
| localhost | debian-sys-maint |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
| localhost | website-php |
| localhost | website-py |
+---------------+------------------+
8 rows in set (0.00 sec)
Вывод моего компа:
saprykin@saprykin-Mi-Laptop-Pro-15:~$ mysql -u sammy -h *SERVER_IP* -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '*SERVER_IP*:3306' (113)
----
UPD Nmap дал такой вывод:
Nmap scan report for *SERVER_IP*
Host is up (0.0035s latency).
Not shown: 997 filtered ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp open https
Он не открыл нужный порт? Если да, то почему... Я перезапускал сервер, поэтому все директивы изменения были примениться