Create a connection user for MySQL and authorize

Source: Internet
Author: User
ArticleDirectory
    • 1. First, log on to the MySQL Command Console
    • 2. Select a data table
    • 3. Add a connection user account in the MySQL user table:
    • 4. Data Table Access Authorization
    • 5. Authorization to take effect. creation is complete.

 

1. First, log on to the MySQL Command Console

After mysqlinstallation, the logging console will be used. For example, you can directly use the logging console to run mysql.exe under the mysqlinstallation directory, and enter the mysql-u root and password to log on to MySQL.

 

 

Executable in the MySQL/bin directoryProgramAnd functions are listed in the following table (refer to the official MySQL instructions ):

mysqld MySQL server
mysqld_safe, MySQL. server, and mysqld_multi server startup script
mysql_install_db initialize the data directory and initial database
mysql a command line Client Program for interactive or batch execution of SQL statements.
mysqladmin customer programs used for management.
mysqlcheck perform table maintenance.
mysqldump and mysqlhotcopy backs up databases.
mysqlimport import data files.
mysqlshow displays information about the information database and table.
myisamchk perform table maintenance.
myisampack compress and read-only tables.
mysqlbinlog it is a utility used to process binary log files.
perror display the meaning of the error Code .
2. Select a data table

Statement: use MySQL;

3. Add a connection user account in the MySQL user table:

Here, do not directly use the insert statement to add user records. Insert may occur:

Error 1364 (hy000): field 'ssl _ cipher 'doesn' t have a default value error. However, I did not see this error in earlier MySQL versions, because tianyuan has been directly modifying the user table or directly using the insert statement. When I upgraded MySQL to 5.1, this error may occur.

We recommend that you use the grant statement for authorization. The statement is as follows:

Grant usage on *. * To 'username' @ 'localhost' identified by 'Password' with grant option;

Last sentence:

Replace "username" with the user name to be authorized, such as clientusr;

Replace "password" with the password set by clientusr;

4. Data Table Access Authorization

After the account is created, authorize the preceding common user to the data table. The default permissions of the connected user added in step 3 are "N" and must be authorized for the account in the DB table,Allow access to a dedicated databaseOf course, super users will not talk about it.

Use the following statement:

Grant select, insert, update, delete, create, drop on tablename. * To 'username' @ 'localhost' identified by 'Password ';

The permissions in this statement are determined based on actual needs:

Replace "tablename" with the table name of the authorized data table

"Username" is the username authorized in step 2.

"Password" is the password set for Step 2 Authorized Users

This grants the select, insert, update, delete, careate, and drop permissions to a data table.

5. Authorization to take effect. creation is complete.

One sentence: flush privileges;

 

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.