首页 > 编程知识 正文

Ubuntu MySQL 重置 root 密码,ubuntu重置root密码

时间:2023-05-03 05:08:30 阅读:239051 作者:2778

Ubuntu MySQL 重置 root 密码

找到 MySQL 配置文件 mysqld.cnf

sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

在文件中找到 skip-external-locking,在它的下一行添加:

skip-grant-tables


保存退出文件,重启 MySQL

sudo service mysql restart

输入命令 mysql,进入MySQL (只需要在命令行下输入mysql就行)

修改root密码

update mysql.user set authentication_string=password('密码') where User='root' and Host ='localhost';


刷新权限,退出 MySQL

flush privileges;quit;


这时你的MySQL密码已经重置完成了,把刚才添加的那条 skip-grant-tables 命令删除,不然对下次 MySQL 启动会有影响。

等等,壮士请留步,给个赞啦,生活不宜,写博客不宜啊。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。