說到MySQL的管理工具,腦裡就浮現了phpMyAdmin,這應該是被拿來管理MySQL的最常用工具了,但其實MySQL本身就有提供蠻好用的管理程式:mysqladmin.exe,但因為是命令列互動式,最後大家還是會選擇有UI介面的,畢竟操作方面才是最重要的。


其實不管是哪個資料庫都會提供這類指令互動程式來操作資料庫,因為資訊保密的重要,最後常常要面對的環境就是一個console介面而已,平常的練習和熟悉指令看來還是必須的。

那就實際來操作一遍mysqladmin.exe吧。
打開一個DOS視窗後,切換到存放MySQL應用程式的資料夾。
以下粗體為實際指令,{}包起來的內容是說明。
D:\WebServer\mysql\bin>mysql -h 127.0.0.1 -u root -p (本行指令:應用程式名稱、指定伺服器、伺服器名稱/網紙、指定使用者、使用者名稱、指定資料庫)
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.14-log MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
(進入管理模式,下列所有指令後面需以;結尾)
mysql> show databases; {察看目前擁有的資料庫清單}
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.08 sec)

mysql> Select user(); {顯示目前擁有的使用者清單}
+----------------+
| user() |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.03 sec)

mysql> use test; {選擇要進行操作的資料庫}
Database changed
mysql> show tables; {顯示資料庫test的資料表清單}
Empty set (0.06 sec)

mysql> create table UsrData (
-> Id int,
-> FirstName varchar(20),
-> LastName varchar(20));
{建立一個資料表}
Query OK, 0 rows affected (0.11 sec)

mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| usrdata |
+----------------+
1 row in set (0.00 sec)

mysql> desc usrdata; {檢視資料表usrdata的欄位定義}
+-----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| Id | int(11) | YES | | NULL | |
| FirstName | varchar(20) | YES | | NULL | |
| LastName | varchar(20) | YES | | NULL | |
+-----------+-------------+------+-----+---------+-------+
3 rows in set (0.06 sec)

mysql> insert into usrdata (Id, FirstName, LastName)
-> values (0, 'Java', 'Sun');

Query OK, 1 row affected (0.03 sec)

mysql> insert into usrdata (Id, firstname, lastname)
-> values (1, 'java', 'oracle');

Query OK, 1 row affected (0.01 sec)

mysql> select * from usrdata;
+------+-----------+----------+
| Id | FirstName | LastName |
+------+-----------+----------+
| 0 | Java | Sun |
| 1 | java | oracle |
+------+-----------+----------+
2 rows in set (0.03 sec)

mysql> select firstname, lastname from usrdata;
+-----------+----------+
| firstname | lastname |
+-----------+----------+
| Java | Sun |
| java | oracle |
+-----------+----------+
2 rows in set (0.00 sec)

mysql> quit; {離開}
Bye

, ,

mark528 發表在 痞客邦 PIXNET 留言(0) 人氣()