First page: MySQL character set creation and CRUD operations

Source: Internet
Author: User
Tags create database

1. Specify the default character set when MySQL database is created
CREATE database $DN_NAME DEFAULT CHARACTER SET utf8mb4 -- UTF-8 Unicode COLLATE utf8mb4_general_ci
Annotations:
>  utf8mb4 -- UTF-8 Unicode:字符集;mb4是在utf8的基础上支持了imoji表情。>  utf8mb4_general_ci:是字符排序方式;>  mysql 创建database时最好能明确指定字符集,防止字符混乱的情况发生。
2 Database user's additions and deletions check and change
    • MySQL User's creation
CREATE USER ‘username‘@‘host‘ IDENTIFIED BY ‘password‘;CREATE USER ‘dog‘@‘localhost‘ IDENTIFIED BY ‘123456‘;CREATE USER ‘pig‘@‘192.168.1.101_‘ IDENDIFIED BY ‘123456‘;CREATE USER ‘pig‘@‘%‘ IDENTIFIED BY ‘123456‘;CREATE USER ‘pig‘@‘%‘ IDENTIFIED BY ‘‘;CREATE USER ‘pig‘@‘%‘;
    • Single-user authorization and its cascade authorization;

      GRANT privileges ON databasename.tablename TO ‘username‘@‘host‘GRANT ALL privileges ON $DB_NAME.$TAB_NAME to ‘$USER_NAME‘@‘$HOST_IP‘ identified by ‘$RANDOM_STRING‘;GRANT privileges ON databasename.tablename TO ‘username‘@‘host‘ WITH GRANT OPTION;
    • User MySQL Password modification
      SET PASSWORD FOR ‘username‘@‘host‘ = PASSWORD(‘newpassword‘);SET PASSWORD = PASSWORD("newpassword");SET PASSWORD FOR ‘pig‘@‘%‘ = PASSWORD("123456");
    • User Rights revocation

      REVOKE privilege ON databasename.tablename FROM ‘username‘@‘host‘;
    • User Rights view;

      SHOW GRANTS FOR ‘pig‘@‘%‘;
    • User Delete
      DROP USER ‘username‘@‘host‘;

First page: MySQL character set creation and CRUD operations

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.