I forgot the password of the root account of the MySQL database. How can I modify the background:
MySQL Database root Account is generally known only to MySQL DBAs, And the password of this account must be kept strictly confidential. Once the leakage is serious, however, if DBAs forget, some MySQL management cannot be performed, at this time, you must reset the root account password without any damage to ensure data security: www.2cto.com
1. stop mysqld Database service shell> service mysql stop Note: if you have the shutdown permission, you can use mysqladmin -- user = xxx-password shutdown to stop mysqld service 2. start mysqld Database Service shell> mysqld -- datadir =/var/data/-- pid-file =/var/data/xxx with the -- skip-grant-tables option. pid -- skip-grant-tables Note: datadir specifies the database data directory, pid-file specifies the file whose content is mysqld process number, and skip-grant-tables specifies the options, ignore permission verification during mysqld startup 3. do not use the password to log on to mysql database shell> mysql-uroot mysql. Note: if the password option (-p or -- password) is not specified, use a blank password to log on. 4. modify the account root password mysql> update user set password = password ('root _ pwd') where user = 'root'; mysql> flush privileges; Note: After the password is changed, you must use the flush privileges statement to make the password take effect. Here, set the root account password to root_pwd www.2cto.com 5. stop mysqld Database service shell> mysqladmin -- user = root-password shutdown Note: This time mysqladmin is used to stop. in linux, the service cannot stop the mysql database server that is manually started. 6. start mysql database shell> service mysql start 7 normally. log on with the new password and find that the password has been changed to the new password shell> mysql-uroot-proot_pwd mysql author chhuma