Password settings for MySQL

Source: Internet
Author: User

The way that MySQL uses usernames and passwords differs a lot from how UNIX or Windows uses them:

· MySQL uses the user name for the authentication purpose, regardless of the UNIX user name (login name) or the Windows user name. By default, most MySQL customers try to log on using the current UNIX username as the MySQL username, but this is only for convenience. The client program allows you to specify a different name with the-U or--user option, which means that you cannot make a database more secure in any case, unless all MySQL user names have a password. Anyone can attempt to connect to the server by any name, and if they specify any name without a password, they will succeed.

· The MySQL username can be up to 16 characters long and typically a UNIX user name is limited to 8 characters.

· The MySQL password does not matter with the UNIX password. There is no need to have a connection between the password you use to log on to a UNIX machine and the passwords that you use to access a database on that machine.

· The MySQL encryption password uses the different algorithms used during a UNIX logon.

This section describes how to modify passwords for users of the MySQL database system.

Using the MyAdmin utility

The command line to modify a password using the Mysqladmin utility is:

shell>mysqladmin-u user-p Password "NewPassword"

Run this command, when prompted to enter a password, the data is the password, the user's password is changed to NewPassword

。 If the original user does not have a password, then the-p option is not specified. For example, after initializing the authorization table, the root user's password is empty, and you can set the password for root:

shell>mysqladmin-u root Password "NewPassword"

Use statement set PASSWORD

Using Mysqladmin to modify the password for the user has an obvious disadvantage, that is, must know the user's original password, if it is to the forgotten password for users to reset the password is powerless. A SQL statement specifically used to modify the password is set PASSWORD:

· SET PASSWORD = PASSWORD (' some PASSWORD ')

Sets the password for the current user. Anyone who is not anonymous can change his own password!

After connecting to the server, you can change your password as follows:

mysql> SET PASSWORD = PASSWORD (' another Pass ');

· SET PASSWORD for user = PASSWORD (' some PASSWORD ')

Sets the password for a specific user on the current server host. Only users who have access to the MySQL database can do so. The user should be given in user@hostname format, where user and hostname are exactly the same as the user and host columns they listed in the Mysql.user table entry. For example, if you have an entry whose user and host fields are ' Bob ' and '%.loc.gov ', you will write:

Mysql> SET PASSWORD for bob@ "%.loc.gov" = PASSWORD ("Newpass");

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.