How to add users and grant permissions in MySQL

Source: Internet
Author: User
Add a user in mysql as follows: 1 use the root user login mysql-uroot-p2 select mysql database usemysql3 Add User insertintou

To add a user to mysql, use the following method: 1. log on to mysql-u root-p using the root user; 2. Select mysql database use mysql 3 and add the user insert into u.

To add a user to mysql, follow these steps:

1. Log On with the root user

Mysql-u root-p

2. Select mysql database

Use mysql

3. Add a user

Insert into user (Host, User, Password) values ("localhost", "your username", password ("your Password "));

Replace Chinese characters with the user name or password you want to use

4. Refresh the MySQL system permission table

Flush privileges;

Add permissions to users:

Assume that I have a database named ysou and a user named honest. I want honest to have all the permissions (add, delete, modify, and query) for all tables in ysou,

The procedure is as follows:

1. Log On with the root user

Mysql-u root-p

2. Add Permissions

Grant all on ysou. * to honest;

3. log out of the root account and use honest to log on to mysql. Use show databases to View tables that can be operated by the current honest account. Of course, you can access the corresponding database to perform operations.

This is only the full authorization of the database. Of course, you can also authorize some operations separately. Click the link for the specific grant.

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.