1.添加环境变量:
右击我的电脑——>属性——>高级系统设置——>环境变量——>系统变量——>Path里添加";C:Program FilesMySQLMySQL Server 8.0in",实际上就是mysql.exe的文件夹。
2.登录数据库:
C:UsersAdministrator>mysql -uroot -p
Enter password: ******
3.创建数据库:
mysql> create database ltlscsdb;
4.查询数据库是否创建:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| ltlscsdb |
| mysql |
| performance_schema |
| sakila |
| sys |
| world |
+--------------------+
7 rows in set (0.00 sec)
5.进入数据库:
mysql> use ltlscsdb;
Database changed
6.查看数据库中是否有表:
mysql> show tables;
Empty set (0.00 sec)
7.增加表:
mysql> create table hamu (csDate VARCHAR(32),trainNo VARCHAR(32),
-> testNo VARCHAR(32),csTime VARCHAR(32),csPosition VARCHAR(32),
-> csDes TEXT,csReason TEXT,csType VARCHAR(32),csRlt TEXT,
-> csRetest TEXT,csOther TEXT);
Query OK, 0 rows affected (0.81 sec)
mysql> show tables;
+--------------------+
| Tables_in_ltlscsdb |
+--------------------+
| hamu |
+--------------------+
1 row in set (0.05 sec)
8.查看增加的字段:
mysql> describe hamu;
+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| csDate | varchar(32) | YES | | NULL | |
| trainNo | varchar(32) | YES | | NULL | |
| testNo | varchar(32) | YES | | NULL | |
| csTime | varchar(32) | YES | | NULL | |
| csPosition | varchar(32) | YES | | NULL | |
| csDes | text | YES | | NULL | |
| csReason | text | YES | | NULL | |
| csType | varchar(32) | YES | | NULL | |
| csRlt | text | YES | | NULL | |
| csRetest | text | YES | | NULL | |
| csOther | text | YES | | NULL | |
+------------+-------------+------+-----+---------+-------+
11 rows in set (0.08 sec)