1 、中止mysql服務mysql
二、找到mysqld_safe (which mysqld_safe )sql
三、無權限驗證啓動mysql (mysqld_safe --skip-grant-tables &)數據庫
四、無密碼登陸mysql (mysql -uroot -p)ip
五、修改mysql數據庫 user 表的對應密碼字段這裏是 authentication_stringstring
(update user set authentication_string=password("pwd") where user = "root")io
六、flush privileges;table
七、中止mysql 正常啓動mysql 用新密碼登陸 。登錄