MySQL在命令行中的常见命令

MYSQL

常见命令:

数据存储位置:datadir=D:\Mylargeprogram\Mysql-8.0.24-winx64\data

打开:cmd以管理员身份运行 ——net start MySQL - -Mysql -u root -p

不区分大小写 单行注释:#注释文字,或者-- 注释文字

 展示数据库
 show databases;   

information_schema: 表格信息

performance_schema:性能信息

查看表格(法一):
mysql> use sys
Database changed
mysql> show tables
    -> ;
+-----------------------------------------------+
| Tables_in_sys                                 |
+-----------------------------------------------+
| host_summary                                  |
| host_summary_by_file_io                       |
| host_summary_by_file_io_type                  |
| host_summary_by_stages                        |
| host_summary_by_statement_latency             |
| host_summary_by_statement_type                |
略
法二
show tables from mysql; 
创建数据库:
create database test;
进入数据库
use test;
查看当前库
select database()
简单表格操作:
mysql> create table stuinfo(
    -> id int,
    -> name varchar(20));
Query OK, 0 rows affected (0.04 sec)
mysql> desc stuinfo;   类型
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id    | int         | YES  |     | NULL    |       |
| name  | varchar(20) | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.01 sec)
mysql> insert into stuinfo (id,name) values(1,'join');
Query OK, 1 row affected (0.01 sec)

mysql> insert into stuinfo (id,name) values(2,'rose');
Query OK, 1 row affected (0.01 sec)

mysql> select *from stuinfo;
+------+------+
| id   | name |
+------+------+
|    1 | join |
|    2 | rose |
+------+------+
2 rows in set (0.00 sec)

查看数据库版本
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.27    |
+-----------+
1 row in set (0.00 sec)

mysql> exit;
Bye

C:\WINDOWS\system32>mysql --version
mysql  Ver 8.0.27 for Win64 on x86_64 (MySQL Community Server - GPL)
法二:mysql --V

你可能感兴趣的:(mysql,数据库)