1. 连接上mysql 授权
grant all privileges on *.* to root@'%' identified by '密码' with grant option;
flush privileges;
修改mysql密码
update mysql.user set password=password("new_pass") where user="root";
2. 检查my.cnf
sudo updatedb
locate my.cnf
如果安装了多个mysql,搞不清楚用哪个配置文件。
命令行连接上mysql 输入status查看
MariaDB [zkt_crm]> status -------------- /opt/lampp/bin/mysql Ver 15.1 Distrib 10.3.16-MariaDB, for Linux (x86_64) using readline 5.1 Connection id: 2982 Current database: zkt_crm Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server: MariaDB Server version: 10.3.16-MariaDB Source distribution Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: latin1 Db characterset: utf8 Client characterset: utf8 Conn. characterset: utf8 UNIX socket: /opt/lampp/var/mysql/mysql.sock Uptime: 6 days 18 hours 53 min 29 sec Threads: 7 Questions: 3465593 Slow queries: 0 Opens: 3203 Flush tables: 1 Open tables: 58 Queries per second avg: 5.909 -------------- MariaDB [zkt_crm]>
可以删掉/etc/my.cnf
注意端口号
bind_address= 0.0.0.0
3. 检查防火墙
sudo emacs /etc/sysconfig/iptables
-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT # 允许3306端口
-A INPUT -p tcp -m tcp --dport 3306 -j DROP # 禁止3306端口
4. 检查vps主机端口限制
安全组配置