How to change the root password of mysql

Source: Internet
Author: User
If it is just installed successfully, the password is empty, Change Password method: mysqladmin-urootpassword11111 password is not empty, Change Password method there are two: 1) mysqladmin-uroot-p111111password1234562) updatemysql. usersetpasswordPASSWORD (123456) whereuserroot #

If the password is blank after the installation is successful, the password can be changed to mysqladmin-u root password '000000'. There are two ways to change the password: 1) mysqladmin-u root-p '000000' password '000000' 2) update mysql. user set password = PASSWORD ('000000') where user = 'root '#


If the password is blank after the installation is successful, change the password as follows:
Mysqladmin-u root password '123'


The password is not blank. There are two methods to change the password:

1)
Mysqladmin-u root-p '000000' password '000000'

2)
Update mysql. user set password = PASSWORD ('000000') where user = 'root'

# Be sure to refresh the permission

Flush privileges;



Remedy for forgetting the root password


Single Instance:
Killall mysqld
Mysqld_safe -- skip-grant-tables & # Start
Mysql-u root-p
Or
Add a row in my. cnf [mysqld]
Skip-grant-tables

Multiple instances:
Killall mysqld
Mysqld_safe -- defaults-file =/data/3306/my. cnf -- skip-grant-table &
Mysql-u root-p-S/data/3306/mysql. sock





Change Password:
Update mysql. user set password = PASSWORD ('oldboys') where user = 'root ';
Flush privileges;


Restart the test after modification:
Killall mysqld
Single Instance:/etc/init. d/mysqd restart
Multi-instance:/data/3306/mysql restart



[Author] Zeng jiansheng

[Author mailbox] zengjiansheng1@126.com

[Author's QQ] 190678908

[Author's blog] blog.csdn.net/newjueqi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.