I have already got a post mentioned to how to change password for MySQL on Linux
You can find it here
https://forumweb.hosting/13207-how-to-change-password-for-mysql-on-linux.html
If you want to do it quickly to have a new password for MySQL on Linux
I will recommend you run these commands
Step 1
Stop the MySQL service on Ubuntu and Debian
Code:
sudo /etc/init.d/mysql stop
or
For CentOS, Fedora, and Red Hat Enterprise Linux
Code:
sudo /etc/init.d/mysqld stop
If you run right command, it will show this
Shutting down MySQL (Percona Server)........... SUCCESS!
Ok, now you can connect to MySQL by runnning the following command:
When you use the command above, it will show messages like this
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.50-38.0 Percona Server (GPL), Release 38.0, Revision b05b24c
Copyright (c) 2009-2016 Percona LLC and/or its affiliates
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.
Step 2
Set a new MySQL root password
Code:
use mysql;
update user set password=PASSWORD("mynewpassword") where User='root';
flush privileges;
quit
Replace
mynewpassword by your password as desired.
You should have messages like this when running commands above
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set password=PASSWORD("mynewpassword") where User='root';
Query OK, 4 rows affected (0.05 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.09 sec)
mysql> quit
Bye
Restart MySql
Code:
sudo /etc/init.d/mysql start
Now you can login with new password you have just changed.
Hope it helps!