忘記mysql管理密碼怎麽辦?
在已知密碼的情況下修改mysql管理密碼:
mysqladmin -uroot -p123 password 123456
情況二:
在忘記mysql登錄密碼的情況下,清空或登錄mysql管理密碼:
1.#停止mysqld服務
/etc/init.d/mysqld stop
2.#使用mysqld_safe啟動服務器。這樣啟動mysql將允許任何人以root用戶和空密碼訪問mysql服務器
#允許本和網絡遠程登錄
/application/mysql/bin/mysqld_safe --skip-grant-tables&
#不允許網絡遠程登錄(建議)
/application/mysql/bin/mysqld_safe --skip-grant-tables --skip-networking &
3.#使用mysql語句直接登錄,這裏不需要密碼
mysql
4#.使用MySQL語句修改密碼,修改授權表
5.6版本:
mysql>use mysql;update mysql.user set password=PASSWORD('123') where user='root' and host='localhost'; #把root用戶更新密碼為 123456
exit #退出
5.7版本中的:password字段改成authentication_strings
update mysql.user set authentication_string=PASSWORD('123') where user='root' and host='localhost';
5.#然後重啟mysql,這樣mysql的root密碼就修改了
/etc/init.d/mysqld restart
忘記mysql管理密碼怎麽辦?