[英]Can't connect to MySQL server remotely
I've read a lot of answers for this question, but didn't found the resolve. 我已经阅读了很多有关此问题的答案,但没有找到解决方法。 I have an mysql server on Azure (ex. 13.25.147.140).
我在Azure(例如13.25.147.140)上有一个mysql服务器。
my.cnf: my.cnf文件:
[mysqld]
# bind-address=127.0.0.1
init_connect= ^`^xSET collation_connection = utf8_unicode_ci ^`^y
character-set-server = utf8
collation-server = utf8_unicode_ci
[client]
default-character-set = utf8
Then, I did sudo service mysql restart
然后,我做了
sudo service mysql restart
Then, granted permission for root: 然后,授予root权限:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'57.26.24.157' IDENTIFIED BY 'password' WITH GRANT OPTION;
mysql> SELECT user, host from user;
+------------------+--------------+
| user | host |
+------------------+--------------+
| root | % |
| root | 57.26.24.157 |
| debian-sys-maint | localhost |
| mysql.sys | localhost |
| paymon | localhost |
| phpmyadmin | localhost |
| root | localhost |
+------------------+--------------+
But when I tried to connect from my PC, I got this: 但是,当我尝试从PC连接时,我得到了:
mysql -u root -p -h 13.25.147.140
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'57.26.24.157' (using password: YES)
How can I fix that? 我该如何解决?
By default, mysql disallow root login remotely, it is a security precaution. 默认情况下,mysql禁止远程root登录,这是安全预防措施。 If you want to use root to login remotely for some test, we can use this command to modify it:
如果要使用root远程登录以进行某些测试,我们可以使用以下命令对其进行修改:
[root@jasonvm etc]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select host, user from user where user="root";
+-----------+------+
| host | user |
+-----------+------+
| % | root |
| 127.0.0.1 | root |
| localhost | root |
+-----------+------+
3 rows in set (0.00 sec)
mysql> grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;
Query OK, 0 rows affected (0.00 sec)
Another VM to use root to login mysql: 另一个使用root登录mysql的VM:
[root@localhost ~]# mysql -u root -p -h 40.71.33.231
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.