การใช้งาน MySQL (1)

มาลองใช้คำสั่งของ MySQL กันนะครับ

root@sothorn:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9 to server version: 5.0.22-Debian_0ubuntu6.06-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| backupmon |
| mysql |
+--------------------+
3 rows in set (0.00 sec)

mysql> use mysql;
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_mysql |
+---------------------------+
| columns_priv |
| db |
| func |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| host |
| proc |
| procs_priv |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
17 rows in set (0.00 sec)

mysql>
-----

shell # mysql -u root -p # เข้าใช้งานฐานข้อมูล
mysql> show databases; # ให้แสดงชื่อฐานข้อมูลที่มีทั้งหมด
mysql> use mysql; #เข้าไปทำงานกับฐานข้อมูลที่ชื่อ myql
mysql> show tables; #ให้แสดง tables ในฐานข้อมูลที่เลือกใช้