您好,登錄后才能下訂單哦!
今天在CentOS 6.5上安裝mysql5.7時(shí)遇到一個(gè)問題,沒有初始化密碼。
在mysql5.7之前的版本首次登陸是無需密碼的,但是5.7起會(huì)生成一個(gè)初始化密碼/root/.mysql_secert
cat /root/.mysql_secert 就可以查看初始化密碼了
但是我的安裝沒有發(fā)現(xiàn).mysql_secert文件。
這種情況的解決方案:
mysqld_safe --user=mysql --skip-grant-tables &
#跳過授權(quán)驗(yàn)證方式啟動(dòng)mysql
mysql -uroot -p
>use mysql;
>desc user;
#發(fā)現(xiàn)沒有了password這個(gè)密碼參數(shù)
...略
| authentication_string | text | YES | | NULL | |
| password_expired | enum(
'N'
,
'Y'
) | NO | | N | |
| password_last_changed | timestamp | YES | | NULL | |
| password_lifetime | smallint(5) unsigned | YES | | NULL | |
| account_locked | enum(
'N'
,
'Y'
) | NO | | N | |
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
>
select
user,host,authentication_string,password_expired from user;
+-----------+-----------+-------------------------------------------+------------------+
| user | host | authentication_string | password_expired |
+-----------+-----------+-------------------------------------------+------------------+
| root | localhost | *9AA01F6E2A80A823ACB72CC07337E2911404B5B8 | Y |
| mysql.sys | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | N |
+-----------+-----------+-------------------------------------------+------------------+
#到這里不難發(fā)現(xiàn)root賬戶的密碼已過期,還比5.6多出了一個(gè)mysql.sys用戶
>update user
set
authentication_string=password(
'123456'
) where user=
'root'
;
#修改密碼為123456
>flush privileges;
重新登錄mysql,首先停掉所有mysql進(jìn)程
mysqld_safe --user=mysql &
mysql -uroot -p
>show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
#報(bào)錯(cuò),需要使用alter user 修改密碼,所以登陸進(jìn)來的第一件事情是修改mysql的初始密碼。否則使用會(huì)報(bào)錯(cuò)
> alter user root@
'localhost'
identified by
'aolens123..'
;
#這下就好了
可以看到5.7的密碼字段改成了authentication_string,
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。