解决linux下mysql-server的一些问题

root用户无需密码即可登录

  1. 使用root用户登录mysql

  2. 切换到mysql数据库

use mysql;
  1. 使用下面的命令设置密码
update user set authentication_string=password('新密码'), plugin='mysql_native_password' where user='root';

这是因为mysql5.7之后user中原本的password字段已经变更为 authentication_string 字段。

  1. 接着执行下面的命令
FLUSH PRIVILEGES;

开放外网可以连接

  1. 编辑/etc/mysql/mysql.conf.d/mysqld.cnf文件,将里面的bind-address字段注释掉即可;

  2. 重启mysql服务,使用下面的命令

systemctl restart mysql.service 
posted @ 2022-12-06 19:08  万物小白  阅读(75)  评论(0编辑  收藏  举报