Linux環境下初涉MySQL

來源:互聯網
上載者:User

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>

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.