wmh1997

编辑my.cnf允许空密码登录

1 [root@7Core ~]# vi /etc/my.cnf
2 #在[mysqld]下加入一行
3 skip-grant-tables=1

重新启动Mysql服务

1 [root@7Core ~]# systemctl restart mysqld.service

使用Root登录数据库、使用mysql数据库、修改root密码、退出数据库

1 [root@7Core ~]# mysql -u root
2 mysql> use mysql;
3 mysql> update user set authentication_string = password(\'新密码\'),password_last_changed=now() where user=\'root\';
4 mysql> exit;

再次打开my.cnf,将skip-grant-tables=1删掉,保存退出

1 [root@7Core ~]# vi /etc/my.cnf
2 #删除skip-grant-tables=1

重启Mysql服务

1 [root@7Core ~]# systemctl restart mysqld.service

分类:

技术点:

相关文章: