mysql 基本知識(shí)和phpMyAdmin的配制Faq
平時(shí)都是在用oracle,這次做項(xiàng)目開(kāi)始用mysql,寫一下mysql的一些基本知識(shí)和phpMyAdmin的配制Faq
一,mysql的常用操做
1.導(dǎo)出整個(gè)數(shù)據(jù)庫(kù)
mysqldump -u 用戶名 -p 數(shù)據(jù)庫(kù)名 > 導(dǎo)出的文件名
mysqldump -u wcnc -p smgp_apps_wcnc > wcnc.sql
2.導(dǎo)出一個(gè)表
mysqldump -u 用戶名 -p 數(shù)據(jù)庫(kù)名 表名> 導(dǎo)出的文件名
mysqldump -u wcnc -p smgp_apps_wcnc users> wcnc_users.sql
3.導(dǎo)出一個(gè)數(shù)據(jù)庫(kù)結(jié)構(gòu)
mysqldump -u wcnc -p -d --add-drop-table smgp_apps_wcnc >d:\wcnc_db.sql
-d 沒(méi)有數(shù)據(jù) --add-drop-table 在每個(gè)create語(yǔ)句之前增加一個(gè)drop table
4.導(dǎo)入數(shù)據(jù)庫(kù)
常用source 命令
進(jìn)入mysql數(shù)據(jù)庫(kù)控制臺(tái),
如mysql -u root -p
mysql>use 數(shù)據(jù)庫(kù)
然后使用source命令,后面參數(shù)為腳本文件(如這里用到的.sql)
mysql>source d:\wcnc_db.sql
5,更改mysql數(shù)據(jù)庫(kù)的編碼
?/etc/my.cnf 加入
?default-character-set=utf8
二,mysql的常見(jiàn)問(wèn)題
1,能本機(jī)登陸,不能遠(yuǎn)程登陸
mysql的系統(tǒng)數(shù)據(jù)庫(kù)是mysql,里邊有一個(gè)表user,user表的一個(gè)字段host,決定了能在什么地方訪問(wèn)mysql
?localhost代表本機(jī)
?%代表任何機(jī)器
?如果你想在遠(yuǎn)程使用root,同時(shí)還要給本機(jī)的一些服務(wù)提供使用,那么可以建立兩個(gè)root用戶
三,phpMyAdmin的配制
雖然還有一些工具也很好用,但是phpMyAdmin無(wú)疑是其中的佼佼者,至少使用人數(shù)上是,安裝網(wǎng)上有很多,
這里寫一下安裝過(guò)程中常遇到的問(wèn)題和解決辦法.
1,不能加載mysql擴(kuò)展
須要安裝一個(gè)類似php-mysql的包。
2,每次進(jìn)入要求登陸,加上這兩句:
$cfg['Servers'][$i]['user'] = 'username';
$cfg['Servers'][$i]['password'] = 'password';
3,一些頁(yè)面的下方提示sql語(yǔ)句錯(cuò)誤
原因:沒(méi)有導(dǎo)入數(shù)據(jù)庫(kù)
找到你的phpMyAdmin的目錄,里邊有個(gè)script目錄,導(dǎo)入里邊的腳本。create_tables.sql
mysql版本高的話導(dǎo)入另一個(gè)create_tables_mysql_4_1_2+.sql
解決辦法 mysql -u root -p
mysql> source create_tables.sql
?
?
?
?
?
?
?
?
posted on 2006-11-24 19:02 dreamstone 閱讀(514) 評(píng)論(0) 編輯 收藏 所屬分類: 利器