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

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

黄舟
Release: 2017-06-18 10:56:51
Original
3704 people have browsed it

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;查询数据
Copy after login

7.quit;Exit

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

mysql> SHOW DATABASES;
Copy after login

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;
Copy after login

3. Display the structure of the data table:

mysql> DESCRIBE 表名;
Copy after login

4. Create the database:

mysql> CREATE DATABASE 库名;
Copy after login

5 , Create a data table:

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

6. Delete the database:

mysql> DROP DATABASE 库名;
Copy after login

7. Delete the data table:

mysql> DROP TABLE 表名;
Copy after login
Copy after login

8. Clear the records in the table:

mysql> DROP TABLE 表名;
Copy after login
Copy after login

9. Display records in the table:

mysql> SELECT * FROM 表名;
Copy after login

10. Insert records into the table :

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

11. Update data in the table:

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

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

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

13. Import .sql file command:

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

14. Change the root password on the command line:

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

15. Display the database name of use:

mysql> SELECT DATABASE();
Copy after login

16. Display the current user:

MySQL> SELECT USER();
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template