This document lists some of the commonly used SQL statements. For more information about the SQL statements including command parameters and restrictions, see MySQL 5.7 Reference Manual.

Database-related commands

Operation Command
Create a database and designate a character set.
create database db01 DEFAULT CHARACTER SET gbk COLLATE gbk_chinese_ci;
Delete a database.
drop database db01;

Account-related commands

If an instance has a master account, passwords of other accounts/users under this instance cannot be changed by the master account. If the password needs to be changed, you must delete this account and create a new one.
Operation Command
Create an account.
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
Delete an account.
DROP USER 'username'@'host';
Authorize the account.
GRANT SELECT ON db01. * TO 'username'@'host';
Query the created accounts in the database.
SELECT user,host,password FROM mysql.user_view;
show grants for xxx
Reclaim permissions.
  • Reclaim all permissions:
  • Reclaim specific permissions:
    REVOKE UPDATE ON *. * FROM 'username'@'host';