To modify the MySQL password:
Copy Code code as follows:
Mysqladmin-u root-p Password 123456
Mysqladmin-u username-p Old password password new password
Forget MySQL password:
Copy Code code as follows:
Chown-r Mysql:mysql/var/lib/mysql
/etc/init.d/mysql stop or kill-9 kill the process.
[Root@corshetlpro01 bin]# Cd/usr/local/mysql/bin
./mysqld_safe--user=mysql--skip-grant-tables--skip-networking &
[Root@corshetlpro01 bin]# Ps-ef | grep MySQL
Root 26544 25356 0 15:08 pts/18 00:00:00/bin/sh./mysqld_safe--user=mysql--skip-grant-tables--skip-networking
MySQL 26673 26544 0 15:08 pts/18 00:00:00/usr/local/mysql/libexec/mysqld--basedir=/usr/local/mysql--datadir=/var/ Lib/mysql--user=mysql--skip-grant-tables--skip-networking--log-error=/var/lib/mysql/corshetlpro01.err-- Pid-file=/var/lib/mysql/corshetlpro01.pid--socket=/tmp/mysql.sock--port=3306
Root 27223 25356 0 15:08 pts/18 00:00:00 grep mysql
./mysql-u Root
mysql> use MySQL;
mysql> Update user Set Password=password (' NewPassword ') where user= ' root ';
mysql> flush Privileges;
Mysql> quit
#/etc/init.d/mysql Restart
# mysql-uroot-p
Enter Password: < Enter the new password newpassword>