mysql远程连接报ERROR 2003
今天远程连接mysql的时候,提示了一个错误:**ERROR 2003 (HY000): Can't connect to MySQL server on**
服务器里查看mysql是否启动:
ps aux|grep mysql显示已开启。
查看配置my.cnf配置文件:
[mysqld] bind-address = 0.0.0.0 # 表示允许任何主机登陆MySQL port=3306 # 表示MySQL运行端口为3306
服务器中登录mysql,查看mysql运行的实际端口
show global variables like 'port'; # 查看MySQL运行的实际端口 +---------------+---------------+ | Variable_name | Value | +---------------+---------------+ | port | 3306 | +---------------+---------------+ 1 row in set (0.01 sec)
继续查看mysql的host
select host,user from user;
没有对应的host
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;