Mysql workbench是Mysql官方推出的數(shù)據(jù)庫設計建模工具,它是著名的數(shù)據(jù)庫設計工具DBDesigner4的繼任者。你可以用MySQL Workbench設計和創(chuàng)建新的數(shù)據(jù)庫圖示,建立數(shù)據(jù)庫文檔,以及進行復雜的MySQL 遷移。MySQL Workbench是下一代的可視化數(shù)據(jù)庫設計、管理的工具,它同時有開源和商業(yè)化的兩個版本。
基本簡介
MySQL Workbench提供DBAs和developers一個集成工具環(huán)境,可用于1)數(shù)據(jù)庫設計和建模;2)SQL開發(fā)(取代原來的MySQL Query Browser);3)數(shù)據(jù)庫管理(取代原來的MySQL Administrator)!
使用方法
Mysql workbench中文語言設置方法:
edit --> preferences --> appearance --> configure Fonts for : 選中Simplified Chinese OK
1)Server Administration
* 使用MySQLInstanceConfig配置MySQL以Service運行;
* 然后使用MySQL Workbench的Server Administration的New Server Instance創(chuàng)建新的server實例@localhost;
* 使用MySQL Workbench的Server Administration的Data Dump來導入我們的數(shù)據(jù)庫實例sakila-db,首先導入sakila schema,然后導入sakila data,導入schema如下圖:
* 導入的命令行可以在workbench的log中看到,schema的導入如下:
mysql.exe --defaults-extra-file="c:\users\AAA\appdata\local\temp\tmphjwdop" --host=localhost --user=root --port=3306 --default-character-set=utf8 --comments < "E:\\mysql\\sakila-db\\sakila-db\\sakila-schema.sql"
data的導入如下:
mysql.exe --defaults-extra-file="c:\users\AAA\appdata\local\temp\tmpbsop_e" --host=localhost --user=root --port=3306 --default-character-set=utf8 --comments < "E:\\mysql\\sakila-db\\sakila-db\\sakila-data.sql"
* 同時也可以使用MySQL Workbench的Server Administration的Data Dump來導出數(shù)據(jù)庫,導出有兩種格式,第一為導出到dump project folder,每個表為一個sql文件,第二種為導出為self contained file,所有的表導出為一個sql文件;
2)SQL Development
* 使用MySQL Workbench的SQL Development的 new connection來創(chuàng)建鏈接localhost,鏈接到先前導入的數(shù)據(jù)庫實例sakila,如下:
* 在MySQL Workbench的SQL Development的環(huán)境中查詢數(shù)據(jù)庫實例sakila的actor表內容,如下:
3)Data Modeling
* 使用MySQL Workbench的Data Modeling的open existing EER model來打開數(shù)據(jù)庫實例sakila中的sakila.mwb文件,如下圖:
* 通常地,我們使用MySQL Workbench的Data Modeling從建模開始來設計數(shù)據(jù)庫,在建模完成后導出為sql語句,然后再將sql導入到數(shù)據(jù)庫,來完成數(shù)據(jù)庫的創(chuàng)建;