How to create a six character password in MySQL 5.7
You are using the password validation plugin. By default it only allows 8 characters and longer passwords. Because it can't check the value of a hash, @RiggsFolly is correct that pre-hashing the password will work.
However, if you want to change the options, you'll need to set the value of the validate_password_length
system variable. You can do this in the configuration file or:
SET GLOBAL validate_password_length=6;
First you login with mysql -u root -p
and check the current policy rules by:
# SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_dictionary_file | |
| validate_password_length | 5 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
+--------------------------------------+--------+
Then you can change any of the above variables at your will:
# SET GLOBAL validate_password_length = 5;
# SET GLOBAL validate_password_number_count = 0;
# SET GLOBAL validate_password_mixed_case_count = 0;
# SET GLOBAL validate_password_special_char_count = 0;
Finally you can create a database and a user accessing it with a simpler password:
# CREATE DATABASE test1;
# GRANT ALL PRIVILEGES ON test1.* TO user1@localhost IDENTIFIED BY "pass1";
# FLUSH PRIVILEGES;
After that you can login with mysql -u user1 -p test1
using password pass1
MySQL 5.7+ by default haves a Password validation system. In case if you don't want to go strictly with the policy and need to assign your own then just disable the password validation and restart mysqld process.
Edit my.cnf file :
vi /etc/my.cnf
in [mysqld]
validate-password=off
Save the file and then restart the process
sudo service mysqld restart
or
systemctl restart mysqld
and then change the Root Password using the following and follow the steps it won't throw exception for the Root Password.
mysql_secure_installation
or
/usr/bin/mysql_secure_installation
If you are doing installation for the first time and want to know the temporary password then use the following to find the first time password:
grep 'temporary password' /var/log/mysqld.log
Let me know your comments on the same, in the below comment box.