2014年4月2日 星期三

管理MySQL資料庫



啟動/關閉

/etc/init.d/mysql start

/etc/init.d/mysql stop

擷取server and database資料

show databases;

show tables

show columns from ...

show table status

show status

show variables

show processlist

show grants for username@host

show privileges

show table types

show create table [tablename]

show create table authors

設定變數

set (global) variable = value

銷毀執行緒

show processlist
...
kill proces_id

清除快取記憶體

手動修改grant table時,可以flush privileges確認改變已經在系統內運作
重組快取查詢 flush query cache
清除快取查詢 reset quest cache

備份
mysqldump -u root -p --databases mylibrary > xxx.sql
mysqldump -u root -p --all-databases > xxx.sql

要復原資料庫可使用『mysql』指令
  復原一個資料庫:
    mysql –u root –p mylibrary < mylibrary _backup.sql
     
   復原多個資料庫: 
    mysql –u root –p < all_backup.sql 






沒有留言:

張貼留言