How to change the Ubuntu 18.04 MySQL Root Password

0
742
sudo apt update
sudo apt install mysql-server
sudo mysql_secure_installation

A series of prompts appear that slightly change the security options for MySQL installation. The first prompt asks if you want to set the Validate Password Plugin to test the strength of the MySQL password. Regardless of your selection, the following prompt sets the password for the MySQL root user: Enter and confirm the desired security password.

You can accept the default values for all subsequent questions here by pressing Y and then ENTER. This removes some anonymous users and test databases, disables remote root login, and MySQL loads these new rules so that changes can be made immediately.

To initialize the MySQL data directory, use mysql_install_db in versions earlier than 5.7.6, and mysqld –initialize in versions later than 5.7.6.However, if you installed MySQL in a Devian distribution, as described in step 1, the data directory is automatically initialized. You don’t have to do anything. If you run the command anyway, the following error

sudo mysql
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’;
mysql> FLUSH PRIVILEGES;

What if you see this error message when you change your password?
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

mysql> uninstall plugin validate_password;
mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘패스워드’;
mysql> FLUSH PRIVILEGES;

LEAVE A REPLY

Please enter your comment!
Please enter your name here