MySQL DCL Data Control language

Source: Internet
Author: User

--Maintenance operations It's all operated under CMD.
To connect to a database :
Native: MySQL [-H-localhost]-u account-p
Remote: MySQL [-H remote_ip]-u account-p

Show all current databases: show databases;
Switch database: Use db_name;
Displays the table under the current database: show tables;

Authorized Remote access:

grant privileges on database. * To User name @ Login host identified by password (pwd_string);
is authorized to take effect:
Restart MySQL Service
Flush privileges;
Privileges:
Select,insert,...
Example : Authorizing Grand Select on studymysql.* to [email protected] ' 172.19.105.5 ' indentified by ' 123456 '

Update permissions flush privileges or restart MySQL set start MySQL

Exit Mysql:exit
To recover access rights :
Revoke privileges on database. * FROM user name @ login host;


--user management:
   --New user
        Create user User_name identified by ' Password_value ';
   --Modify user
        Rename user user_name to New_user_name;
        Set password for user_name = password (' new_password ');
   --delete user
        drop user user_name[,user_name2,...];
   --View users
        Select User,host from Mysql.user;
   --View online users
        SELECT Substring_index (host, ': ', 1) as Host_short,
  &NBSP ;     Group_concat (DISTINCT user) as users,
        COUNT (*) as Threads
    &N Bsp   from Information_schema.processlist
        GROUP by Host_short
      &NB Sp ORDER by COUNT (*), host_short;

--Create a database
Create DATABASE db_name [default character set UTF8 collate utf8_general_ci];

Example : Create DATABASE School default character set UTF8 collate utf8_general_ci;
--Delete Database
Drop database db_name;

Example : Drop Database School;
--Backing up the database
Mysqldump-u user_name-p db_name > Backupfile
Mysqldump-u user_name-p db_name [table_name]> backupfile

example : mysqldump-u root-p Employees > Employees.sql
--Restore Database
Mysql-u root-p
Determines whether the database to be restored exists, does not exist, creates
Switch to the database you want to restore
To perform a restore operation: source Backup.sql

example : 1.mysql-u root-p

2.show databases

3.creat databases Employees default character set UTF8

4.user Employees

5.source Employees.sql

--Programming

MySQL DCL Data Control language

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.