In linux, mysql changes the root password, mysqlroot
Method 1: use the set password command
First, log on to mysql
mysql -u root -p
Then run the set password command.
set password for root@localhost = password('654321');
In the preceding example, change the root password to 654321.
Method 2: Use mysqladmin
Format: mysqladmin-u username-p old password New password
mysqladmin -uroot -p123456 password "654321"
In the preceding example, change the root password from 123456 to 654321.
Method 3: Change the mysql user table
First, log on to mysql
mysql -uroot -p
Then, perform an update operation on the user table of the mysql database.
mysql> use mysql;mysql> update user set password=password('654321') where user='root' and host='localhost';mysql> flush privileges;
Method 4: Forget the password
First stop mysql Service
service mysqld stop
Start mysql by skipping authorization
mysqld_safe --skip-grant-tables &
Log on to mysql as a root user
mysql -u root
Operate the user table of the mysql database for update
mysql> use mysql;mysql> update user set password=password('654321') where user='root' and host='localhost';mysql> flush privileges;mysql> quit
Restart mysql Service
service mysqld restart