Skip to content

Instantly share code, notes, and snippets.

@iandark
Last active February 24, 2021 05:50
Show Gist options
  • Select an option

  • Save iandark/03a9ed674bffe5c05ad5d5c7aca0e489 to your computer and use it in GitHub Desktop.

Select an option

Save iandark/03a9ed674bffe5c05ad5d5c7aca0e489 to your computer and use it in GitHub Desktop.
MySQL 8 change password strengh in mysql console
// 1 - Enter in mysql console
$ mysql -u root
// 1.1 (optional) - if you can't login into mysql console add this in [mysqld] section in your my.cnf file (/etc/mysql/my.cnf):
skip-grant-tables
// 2 - See your password strength
mysql> SHOW VARIABLES LIKE 'validate_password%';
// your output will be something like this:
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 8 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
+--------------------------------------+--------+
7 rows in set (0.01 sec)
// 3 - Paste this cli's to change security strength
mysql> SET GLOBAL validate_password.length = 4;
mysql> SET GLOBAL validate_password.policy = low;
mysql> SET GLOBAL validate_password.mixed_case_count = 0;
mysql> SET GLOBAL validate_password.number_count = 0;
mysql> SET GLOBAL validate_password.special_char_count = 0;
mysql> SET GLOBAL validate_password.check_user_name = 0;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
//or
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'pass';
mysql> FLUSH PRIVILEGES;
// 4 - Finally, exit mysql console (CTRL+D), and restart your mysql service
$ sudo service mysql restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment