ubuntu下mysql连接失败怎么办

1416
2021/1/5 9:15:48
栏目: 云计算
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

ubuntu下mysql连接失败怎么办

ubuntu中连接mysql失败的解决方法

原因:Ubuntu在mysql的配置文件中默认绑定了本机ip,需要修改配置文件并赋予权限。

1.在ubuntu命令行中,打开my.cnf配置文件;


/etc/mysql/my.cnf


2.my.cnf配置文件打开后,在文件进行以下修改:


# 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


3.my.cnf配置文件修改好后,使用service命令启动MySQL;


service mysql start


4.最后,MySQL启动后,使用root用户即可连接到MySQL;


mysql -u root -p



辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读: mysql update 操作中的陷阱