Next I will summarize the two solutions that do not remember the mysql root User Password in linux. If you encounter such problems, try the following solutions.
The safest status is to operate on the server Console and unplug the network cable.
1. Modify MySQL Logon Settings:
# Vi/etc/my. cnf
In the [mysqld] section, add skip-grant-tables.
For example:
[Mysqld]
Datadir =/var/lib/mysql
Socket =/var/lib/mysql. sock
Skip-grant-tables
Save and exit vi.
2. Restart mysqld
#/Etc/init. d/mysqld restart
Stopping MySQL: [OK]
Starting MySQL: [OK]
Method 2
[Root @ localhost/] #
Ii. Killing the mysql process
Method 1: [root @ localhost/] # killall mysqld
Method 2: [root @ localhost/] # ps-aux // view all processes and find the mysql process pid
Then
[Root @ localhost/] # kill pid // pid indicates the mysql process ID
3. Use the -- skip-grant-tables parameter to start mysqld
[Root @ localhost/] #/usr/local/mysql/bin/mysqld_safe -- skip-grant-tables &
// Where/usr.../bin is my mysql installation directory
[Root @ localhost/] #/usr/local/mysql/bin/mysql // enter mysql
Mysql> use mysql // switch to mysql database
Mysql> UPDATE user SET password = password ('000000') WHERE user = 'root ';
// Set the root password to 123456.