MySQL Create user and authorization

Source: Internet
Author: User
Tags dba mysql create mysql backup mysql create user

Rights Management

We know that our top authority manager is the root user, and it has the highest permissions. Includes select, Update, delete, update, Grant, and so on. So in general, after the company, the DBA engineer creates a user and password that allows you to connect to the database and set permissions (or all permissions) for an operation to the current user. Then we need to take a brief look at this:

    • How to create a user and password
    • Authorizing the current user
    • Remove permissions from the current user

If you want to create a new user, the following actions are required:


1. Go to MySQL Database

mysql> Use mysqldatabase changed

2. New User deletion

1. Create User: # Specify ip:192.118.1.1 's MJJ User login create username ' mjj ' @ ' 192.118.1.1 ' identified by ' 123 '; Specify ip:192.118.1. MJJ User Login Create username ' mjj ' @ ' 192.118.1.% ' identified by ' 123 '; # Specify any IP mjj user login Create user ' mjj ' @ '% ' Identified by ' 123 '; 2. Delete user ' user name ' @ ' IP address '; 3. Modify user Rename user ' username ' @ ' IP address ' to ' new username ' @ ' IP address '; 4. Modify password Set password for ' Username ' @ ' IP address ' =password (' new password ');

3. Management of Current user authorization

#查看权限show grants for ' user ' @ ' IP address ' #授权 MJJ the user only has query, insert, and update for DB1.T1 file, grant Select, Insert,update on Db1.t1 to "MJJ" @ '% '; # indicates something Permission, except for Grant, which is the root of the command. MJJ User has any action on the T1 file under DB1 Grant all privileges on  db1.t1 to "mjj" @ '% ';
#mjj用户对db1数据库中的文件执行任何操作
Grant all privileges the  db1.* to "mjj" @ '% ';
#mjj用户对所有数据库中文件有任何操作
Grant all privileges on  * * to  "mjj" @ '% ';
#取消权限
# Cancel any action of MJJ user on db1 t1 file
Revoke all on db1.t1 from ' mjj ' @"%";

# Cancel all permissions of MJJ users from the remote server to all tables DB1 the database

Revoke all on db1.* from ' mjj ' @"%";

Remove all tables from the remote server's MJJ user all databases revoke all privileges on * * from ' mjj ' @ '% ';

PS: In a company, it is generally the DBA engineer to do the authorization work. Give you a username and password, you can connect on it.

4.MYSQL Backup command Line Operations

# Backup: Data table structure + data mysqdump-u root db1 > db1.sql-p# Backup: Data table structure mysqdump-u root-d db1 > db1.sql-p# Import existing data to a database # # # first create a new Database db10;# 2. Import an existing database file into the DB10 database mysqdump-u root-d DB10 < db1.sql-p

MySQL Create user and authorization

Related Article

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.