最近阿里云有活动,就搞了一台服务器玩玩。
https://www.aliyun.com/minisite/goods?userCode=xrgh0g7w
用Docker装上了LNMP。
安装好MySQL后想用Navicat连接一下,没想到一直是超时:
Can't connect to MySQL server on 'xx.xx.xx.xx' (60 "Operation timed out")。
Google一下后发现是root没有支持远端连接,所以按着教程配置分配权限:
https://www.cnblogs.com/jiangzhaowei/p/10989344.html
https://blog.csdn.net/gf0515/article/details/80466213
mysql> grant all PRIVILEGES on *.* to root@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.01 sec)
在查看user数据的时候老是报语句执行错误,
ALTER user 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ALTER user 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root'' at line 4
原来是先要指定库,所以需要先
use mysql;
然后再
select user,host,authentication_string from user;
就可以执行成功了。
执行完之后发现还是连接不上,试着telnet了ip:3306发现不通。
然后发现阿里云需要配置安全规则才能把3306这个端口放出来。
这下终于连上了。