linux mysql忘記root密碼

今天開發人員說開發用測試服務器mysql的root密碼忘記了。mysql

mysql root密碼重置這種事常常碰到今天順便作下筆記sql


環境 OS:CentOS 6.5vim

  mysql:服務器

    wKiom1i37hrzLlZUAAARy4EuinM021.png-wh_50


解決:socket

  在mysql配置文件中添加skip-grant-tables[mysqld]下面ide

vim /etc/my.cnf
測試

[mysqld]ui

#port=7416spa

datadir=/var/lib/mysqlrest

socket=/var/lib/mysql/mysql.sock

user=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

lower_case_table_names=1

log-error=/usr/mysql.log

character-set-server=utf8

skip-name-resolve

skip-grant-tables


[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

skip-grant-tables:在啓動mysql時不啓動g受權表grant-tables

***不改配置文件能夠這樣啓動/usr/bin/mysqld_safe --skip-grant-tables &****


重啓  service mysqld restart

使用空密碼登陸mysql並重置密碼

wKiom1i4wi3QDwX4AAA_GjggE_M789.png-wh_50

wKioL1i4wi2TkSqjAAAoxx29o_w769.png-wh_50

UPDATE mysql.user SET Password = password ("123456") WHERE User = 'root';

退出mysql 改回原配置文件 重啓mysql便可

相關文章
相關標籤/搜索