huawei 华为 ubuntu mysql 访问不了的原因

一. 首先将3306端口添加至安全组, 确保端口没有被封掉

二. 开启服务器上的mysql 权限, 步骤如下

1.mysql>grant all privileges on *.* to 'root'@'%' identified by 'root';

   (%) 表示所有ip

    第1个root表示账户

    第2个root表示密码

2.mysql>flush privileges;

3.停止并重启mysql服务。

停止命令:service mysql stop

启动命令:service mysql start

查看状态:service mysql status

如果以上操作还是不能访问,那么应该是mysql没有允许远程访问。

修改配置文件:

sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
将bind-address = 127.0.0.1注释掉(即在行首加#),如下:

代码如下:

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
# bind-address          = 127.0.0.1
然后重启服务即可访问了。

猜你喜欢

转载自www.cnblogs.com/WalkOnMars/p/12393330.html
今日推荐