Error Setting Password in MySQL Database using the PASSWORD utility

Posted on

Error Setting Password in MySQL Database using the PASSWORD utility

Database : MySQL

Version : 5.7.12

Operating System : Any Operating System which has MySQL database running.

This article discuss about the error which is faced when using PASSWORD function in MySQL database.

First of all, check the version of your MySQL database version using the following command :

  1. Login to your MySQL Console as shown below :

username@hostname:~$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 33
Server version: 5.7.12-0ubuntu1.1 (Ubuntu)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

The above output display the version of MySQL which is used, it is MySQL 5.7.12

  1. Check using the following command :

mysql –version

username@hostname:~$ mysql --version
mysql  Ver 14.14 Distrib 5.7.12, for Linux (x86_64) using  EditLine wrapper
username@hostname:~$

The above command also displays an output of MySQL Distribution 5.7.12, so based on the above information, I am using MySQL Database version 5.7.12 and where in the version itself the PASSWORD function is still available. Please aware that this function according to on-line MySQL Reference Manual will be deprecated in MySQL 5.7.6 and so on when eventually will be removed in future release of MySQL. Below is the screenshot of the information :

password-function-will-be-deprecated
Displaying information in form of image captured from dev.mysql.com site that PASSWORD function will be deprecated and eliminated in the future.

When we need to utilize the PASSWORD utility which is a function provided by MySQL database, sometime we will face error as follows :

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

It means that MySQL doesn’t tolerate password which is consider to be weak. MySQL accept password with the combination of letters, capitalized letters, numbers and symbols.

Below is the actual execution of using PASSWORD function by inserting a new record to a table called ‘user’.  To initialize a password, we are using the PASSWORD function in order to fill the password field.

mysql> INSERT INTO user(username, password) VALUES('james',PASSWORD('password'));
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql>

To be able to initialize the password using PASSWORD function, we need to setup a password which is consisting of combination of letter, capitalized letter, numbers and also symbols as shown below :

mysql> INSERT INTO user(username, password) VALUES('james',PASSWORD('My_Password2016'));
Query OK, 1 row affected, 1 warning (0,01 sec)

 

Leave a Reply