Create a user and authorize MySQL.

Source: Internet
Author: User

1. Command: create user 'username' @ 'host' identified by 'Password ';

Description: username-the username you will create, host-specifies the host on which the user can log on. If a local user can use localhost, if you want to allow the user to log on from any remote host, you can use the wildcard %. password-the user's login password. The password can be blank. If it is blank, the user can log on to the server without the password.

Example: 1. create user 'dog '@ 'localhost' identified by '123 ';

2.Create user 'he 'identified by 'hes'; (this is what I use ).


2. Authorization.

command: grant privileges on databasename. tablename to 'username' @ 'host'

Note: privileges-user operation permissions, such as select, insert, update, etc. use all .; databasename-Database Name, tablename-table name. If you want to grant the user the corresponding operation permissions on all databases and tables, it can be represented by *, as shown in *. *.

1. Grant select, insert on test. User to 'pig' @ '% ';
2. Grant all on *. * To 'pig' @ '% ';

3. Grant all privileges on *. * To username @ localhost identified
By '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.