初涉mysql—linux

1、开启服务
[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>