MySQL access rights system

Source: Internet
Author: User
Tags command line crypt

1. MySQL Username and password

* MySQL uses user names for authentication purposes, regardless of UNIX user name (login name) or Windows user name. By default, most MySQL clients 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. and security considerations, all MySQL user names should have a password.

* MySQL username can be as long as 16 characters, typically, the UNIX user name is limited to 8 characters.

* The MySQL password does not matter with the UNIX password.

* The MySQL encryption password uses the different algorithms used during a UNIX login, PASSWORD () and Encrypt ()

function password (str)

Computes a password string from the plain text password str. This function is used to encrypt the MySQL password in order to store the password in the password column of the user authorization table.

Mysql> Select PASSWORD (' badpwd ');

-> ' 7f84554057dd964b '

PASSWORD () encryption is non reversible. PASSWORD () does not perform password encryption in the same way as the UNIX password encryption. You should not assume that if your UNIX password is the same as your MySQL password, PASSWORD () will result in the same encrypted value stored in the UNIX password file. See Encrypt ().

ENCRYPT (Str[,salt])

Use the Unix crypt () system to invoke encrypted Str. The salt parameter should be a 2-character string. (In MySQL 3.22.16, a salt can be longer than 2 characters.) )

Mysql> Select ENCRYPT ("Hello");

-> ' Vxufajxvarroc '

If crypt () is not available on your system, ENCRYPT () always returns NULL. ENCRYPT () only keeps Str starting at 8 characters and ignores all others, at least on some systems. This is determined by the behavior that is invoked by the underlying crypt () system.

1. Connect with MySQL server

Syntax format:

shell> MySQL [-H host_name][-u User_name][-pyour_pass]

Another form of the-H,-u and-P options is--host=host_name 、--user=user_name and--password=your_pass.

Note: There are no spaces between-p or--password= and the password following it. (It is not safe to specify a password on the command line!) )

For a join parameter that is not on the command line, MySQL uses the default value:

* The default host name is localhost.

* The default user name is your UNIX login name.

* If there is no-p, no password is provided.

Specify the default value parameter:

Specify the connection parameters in the [Client] section of the configuration file for ". My.cnf" in your home directory:

[Client]

Host=host_name

User=user_name

Password=your_pass

Note: The value specified on the command line takes precedence over the value specified in the configuration file and the environment variable

The safest way to do this is to have the client prompt for a password or specify a password in an appropriately protected ". My.cnf" file.

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.