MySQL報(bào)錯(cuò):mysql:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
報(bào)錯(cuò)原因:這是因?yàn)闉榱思訌?qiáng)安全性,MySQL5.7為root用戶隨機(jī)生成了一個(gè)密碼,在error log中,關(guān)于error log的位置,如果安裝的是RPM包,則默認(rèn)是/var/log/mysqld.log。
一般可通過(guò)log_error設(shè)置
? ? ? ?mysql>select@@log_error;
可通過(guò)# grep "password" /var/log/mysqld.log 命令獲取MySQL的臨時(shí)密碼
1.如果用該密碼登錄到服務(wù)端后,必須馬上修改密碼,不然會(huì)報(bào)如下錯(cuò)誤:
????????mysql>selectuser();
????????ERROR 1820(HY000): You must reset your password usingALTERUSERstatement before executing this statement.
2.如果只是修改為一個(gè)簡(jiǎn)單的密碼,會(huì)報(bào)以下錯(cuò)誤:
????????mysql>ALTERUSERUSER() IDENTIFIEDBY'12345678';
????????ERROR 1819(HY000): Your password doesnotsatisfy thecurrentpolicy requirements
這個(gè)其實(shí)與validate_password_policy的值有關(guān)。
有時(shí)候,只是為了自己測(cè)試,不想密碼設(shè)置得那么復(fù)雜,譬如說(shuō),我只想設(shè)置root的密碼為123456。
必須修改兩個(gè)全局參數(shù):
首先,修改validate_password_policy參數(shù)的值
????????mysql>setglobal validate_password_policy=0;
????????Query OK, 0rows affected (0.00sec)
這樣,判斷密碼的標(biāo)準(zhǔn)就基于密碼的長(zhǎng)度了。這個(gè)由validate_password_length參數(shù)來(lái)決定。
????????mysql>select@@validate_password_length;
????????mysql>select@@validate_password_length;
????????mysql>setglobal validate_password_length=1;
????????mysql>select@@validate_password_length;
????????mysql>select@@validate_password_length;
????????mysql>select@@validate_password_mixed_case_count;
????????mysql>setglobal validate_password_mixed_case_count=2;
????????mysql>select@@validate_password_mixed_case_count;
????????mysql>select@@validate_password_length;