Section No. 276, MySQL database common commands

Source: Internet
Author: User

MySQL Database common commands

1. Display Database

SHOW DATABASES; Display Database

SHOW DATABASES;

MySQL-User rights-related data
SYS-a table in which the database's related configuration resides
INFORMATION_SCHEMA MySQL itself schema-related data
Performance_schema is primarily used to collect database server performance parameters

2. Create a database

CREATE database name DEFAULT CHARSET UTF8 COLLATE utf8_general_ci; Create a UTF-8 encoded database

Jxiou DEFAULT CHARSET UTF8 COLLATE utf8_general_ci;

CREATE database name DEFAULT CHARACTER SET GBK COLLATE gbk_chinese_ci; Create a GBK encoded database

CREATE DATABASE jxioujjj DEFAULT CHARACTER SET gbk COLLATE gbk_chinese_ci;

3. Using the Database

Use database name; Select a specified database

Use Jxiou

Show TABLES; display all tables in the currently used database

SHOW TABLES;

4. Delete Database

drop database name; To delete a specified database

Drop database jxioujjj;

5. User Management

Note: The default root user is the Super administrator

Create user

Create user ' username ' @ ' IP address ' identified by ' password '; Create a user

Create user ' xyhu ' @ ' 127.0.0.1 ' identified by ' 279819 ';

View all users in the MySQL database

SELECT DISTINCT CONCAT (' User: ', user, ' @ ', host, '; ') as query from Mysql.user;

SELECT DISTINCT CONCAT (' User: ', user, ' @ ', host, '; ') as query from Mysql.user;

Delete User

  drop user ‘用户名‘@‘IP地址‘;

Drop user ' xyhu ' @ ' 127.0.0.1 ';

Modify User Name

  rename user ‘用户名‘@‘IP地址‘ to ‘新用户名‘@‘IP地址‘;

Rename user ' Xyhu ' @ ' 127.0.0.1 ' to ' xyhuuu ' @ ' 127.0.0.1 ';

Change Password

  set password for‘用户名‘@‘IP地址‘= Password(‘新密码‘);

Set password for ' root ' @ ' localhost ' = password (' 279819 ');

Section No. 276, MySQL database common commands

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.