Mysql密碼忘記了怎麼辦?

中止mysql:

sudo /etc/init.d/MySQL stop(可能有其它的方法,總之中止MySQLd的運行就能夠了)mysql

修改mysql的配置文件:

/etc/mysql/mysql.conf.d/mysqld.cnf文件中添加skip-grant-tables每臺電腦的文件位置可能不一樣。sql

從新啓動mysql:

sudo /etc/init.d/MySQL startspa

而後用空密碼方式使用root用戶登陸 MySQL:

MySQL -u rootrest

修改root用戶的密碼:

update MySQL.user set password=PASSWORD('newpassword') where User='root';flush privileges;code

從新啓動MySQL:

/etc/init.d/MySQL restartip

就能夠使用新密碼 newpassword 登陸了。it

相關文章
相關標籤/搜索