Password setting for mysql

Source: Internet
Author: User
Method 1: the simplest method is the method prompted by the system after mysql is installed. Use mysqladmin. Double quotes behind the shellmysqladmin-urootpasswordnewpwdshellmysqladmin-uroot-hhost_namepasswordnewpwdpassword are not mandatory, but if the password contains null or special

Method 1: the simplest method is the method prompted by the system after mysql is installed. Use mysqladmin. Shell mysqladmin-u root password newpwd shell mysqladmin-u root-h host_name password newpwd password is not a required double quotation mark, but if the password contains null or some special

Method 1: the simplest method is the method prompted by the system after mysql is installed. Use mysqladmin.

Shell> mysqladmin-u root password "newpwd"

Shell> mysqladmin-u root-h host_name password "newpwd"

The double quotation marks after the password are not mandatory. However, if the password contains spaces or some special symbols, you must use quotation marks.

Method 2: Use the set password command in mysql to complete the operation. Note that you must use the PASSWORD () function to encrypt the newpwd SET. Otherwise, directly = 'newpwd' will not take effect. However, if you use mysqladmin password or GRANT to set the PASSWORD, you do not need to use the password () function because they have automatically called this function.

Shell> mysql-u root

Mysql> set password for 'root' @ 'localhost' = PASSWORD ('newpwd ');

Mysql> set password for 'root' @ 'host _ name' = PASSWORD ('newpwd ');

Method 3: directly set the password shell> mysql-u root through the UPDATE user table

Mysql> UPDATE mysql. user SET Password = PASSWORD ('newpwd ')

-> WHERE User = 'root ';

Mysql> flush privileges;

If you forget the mysql root Password, perform the following steps to reset it:

1. Kill all mysql Processes

2. Use the -- skip-grant-tables parameter to start mysql.

Shell> mysqld_safe -- skip-grant-tables &

3. Set a new password. You can select either of the two methods.

Method 1

Shell> mysqladmin-u root flush-privileges password "newpwd"

Method 2

Mysql> UPDATE mysql. user SET Password = PASSWORD ('newpwd ')

-> WHERE User = 'root ';

Mysql> flush privileges;

4. Stop mysql server and start it in normal mode

5. OK. You can use the new password.

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.