忘记了mysql的密码,可以按照以下步骤重置,笔者的机器为Ubuntu系统:
停止mysql服务:service mysql stop 打开配置文件: vi /etc/mysql/mysql.conf.d/mysqld.cnf 在[mysqld]的段中加上一句:skip-grant-tables 保存并且退出vi。 启动mysql服务:service mysql start 登录并修改MySQL的root密码 修改密码: update mysql.user set authentication_string=PASSWORD(‘123456‘) where User=‘root‘; # 修改密码 重启服务:service mysql restart此外,mysql默认只允许本地连接就localhost,为了能够让远程机器连接,需要修改my.user表里的Host列为%,语句如下:
update mysql.user set Host=‘%‘ where User=‘root‘
MySql忘记密码后重置
标签:localhost tables 系统 重置 连接 grant stop 远程机器 ubuntu
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did118125