Home  >  Article  >  Database  >  Detailed explanation of commands used by MySQL5.7 mysql command line client

Detailed explanation of commands used by MySQL5.7 mysql command line client

黄舟
黄舟Original
2017-06-18 10:56:513671browse

This article mainly introduces the commands used by MySQL 5.7 mysql command line client. Friends who need it can refer to it

MySQL 5.7

MySQL command line client uses commands

1. Enter password: ******

2.ues mysql;Use Mysql

3.show databases;Show database

4 .use register; use the database name register

5.show tables; display the tables in the register database

6.describe user; operate on the table user:

insert into user(username,password) values("xiaoyan","123456");插入数据
insert into user(username,password) values("ff","123456");插入数据
delete from user where username="xiaoyan";删除数据
update user set username="xiaoyan" where username="ff";更新数据
select * from user;查询数据

7.quit;Exit

1. Display the database list in the current database server:

mysql> SHOW DATABASES;

Note: There is MYSQL system information in the mysql library. We change the password andAddUsers actually use this library to operate.

2. Display the data table in the database:

mysql> USE 库名;
mysql> SHOW TABLES;

3. Display the structure of the data table:

mysql> DESCRIBE 表名;

4. Create the database:

mysql> CREATE DATABASE 库名;

5 , Create a data table:

mysql> USE 库名;
mysql> CREATE TABLE 表名 (字段名 VARCHAR(20), 字段名 CHAR(1));

6. Delete the database:

mysql> DROP DATABASE 库名;

7. Delete the data table:

mysql> DROP TABLE 表名;

8. Clear the records in the table:

mysql> DROP TABLE 表名;

9. Display records in the table:

mysql> SELECT * FROM 表名;

10. Insert records into the table :

mysql> INSERT INTO 表名 VALUES (”hyq”,”M”);

11. Update data in the table:

mysql-> UPDATE 表名 SET 字段名 1='a',字段名2='b' WHERE 字段名3='c';

12. Load data into the data table in text mode:

mysql> LOAD DATA LOCAL INFILE “D:/mysql.txt” INTO TABLE 表名;

13. Import .sql file command:

mysql> USE 数据库名;
mysql> SOURCE d:/mysql.sql;

14. Change the root password on the command line:

mysql> UPDATE mysql.user SET password=PASSWORD('新密码') WHERE User='root';
mysql> FLUSH PRIVILEGES;

15. Display the database name of use:

mysql> SELECT DATABASE();

16. Display the current user:

MySQL> SELECT USER();

The above is the detailed content of Detailed explanation of commands used by MySQL5.7 mysql command line client. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn