云服务器如何重设mysql密码(linux系统)?

linux系统

1. 先结束mysql进程#killallmysqld

用mysql安全模式运行并跳过权限,用root登录,此时不需要密码

#mysqld_safe–skip-grant-tables

#mysql–uroot


2. 现在开始重设密码

#mysql>usemysql;

Readingtableinformationforcompletionoftableandcolumnnames

Youcanturnoffthisfeaturetogetaquickerstartupwith–A

Databasechanged

Mysql>upsateusersetPassword=newpasswordwhereuser=‘root’;

QueryOK,2rowsaffected(0.02sec)

Rowsmatched:2Changed:2Warnings:0

Mysql>quit


3. 重新启动mysql服务

#servicemysqldrestart