Huu Phan | Blog Linux operating system | Linux operating system -Blog Huu Phan | www.huuphan.com

This Blog is protected by DMCA.com

huuphan.com. Powered by Blogger.

How to MySQL change user password

In this tutorial, How do i use MySQL change user password. MySQL and MariaDB are the popular open source Database for Linux Opearating System.

 

Mysql change root password

Note: MySQL default root password is empty when you installed Mysql or MariaDB.
Now, How to reset Mysql root or other users password on linux.

For MySQL 5.7 or above version

Step 1: Open the command terminal.
sudo mysql -u root
Step 2: select the database.
use mysql;
Step 3: Change the root password.
UPDATE mysql.user SET authentication_string=PASSWORD('YOUR_NEW_PASSWORD') WHERE USER='root';
FLUSH PRIVILEGES;
exit

For MySQL 5.7 version or older version

Step 1: Open the command terminal.
sudo mysql -u root
Step 2: select the database.
use mysql;
Step 3: To change the MySQL root user password.
update user set password=PASSWORD("YOUR_NEW_PASSWORD") where User='root';
FLUSH PRIVILEGES;
exit
 Step 4: restart the MySQL service
systemctl restart mysql

MySQL command to change a user password

MySQL show users
SELECT User FROM mysql.user;
Step 1: Open the command terminal
sudo mysql -u root  -p
Step 2: Switch to MySQL database
use mysql;
Step 3: Change the USER password
MySQL database server version 5.7.5 or older versions
SET PASSWORD FOR 'YOUR_USER_NAME'@'localhost' = PASSWORD('NEW_PASSWORD');
MySQL database server version 5.7.6 or above.
ALTER USER 'YOUR_USER_NAME'@'localhost' IDENTIFIED BY 'NEW_PASSWORD';

post new :

Huu Phan | Blog Linux operating system | Huu Phan ~ Zimbra Mail Server,linux,bash script,centos,linux command | www.huuphan.com