CentOS just installed MySQL generally need to reset the MySQL password, can be reset in the following ways.
Method One,
JS Code
#/etc/init.d/mysqld Stop
# Mysqld_safe--user=mysql--skip-grant-tables--skip-networking &
# mysql-u Root 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 newly set password newpassword>
Mysql>
Method Two,
JS Code
Use the user name and password provided directly in the [client] section of the/etc/mysql/debian.cnf file:
# mysql-udebian-sys-maint-p
Enter Password: < Enter the password for the [client] section >
mysql> UPDATE user SET Password=password (' NewPassword ') where user= ' root ';
mysql> FLUSH privileges;
Mysql> quit
# mysql-uroot-p
Enter Password: < Enter the newly set password newpassword>
Mysql>
Remote Access support:
Mysql>use MySQL;
Mysql>update User Set host = '% ' where user = ' root '; --% can be changed to IP or other
Mysql>select host, user from user;
Restart database
Setup MySQL root password under CentOS