1、Linux環境下開啟服務
[xxx@localhost ~]$ su
口令:
[xxx@localhost xxxxx]# /etc/init.d/mysqld start
啟動 MySQL: [確定]
2、登入
[xxx@localhost xxxxx# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.37 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
3、顯示資料庫
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| myDatabase |
| mysql |
| test |
+--------------------+
4 rows in set (0.00 sec)
4、顯示資料庫myDatabase資料庫中的表
mysql> use myDatabase;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+----------------------+
| Tables_in_myDatabase |
+----------------------+
| user |
+----------------------+
1 row in set (0.00 sec)
mysql>
5、顯示表user結構
mysql> describe user;
+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| userID | int(11) | YES | | NULL | |
| userName | varchar(20) | YES | | NULL | |
| userAddress | varchar(100) | YES | | NULL | |
+-------------+--------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql>