mysql备份恢复
要備份 MySQL 資料庫主要分為兩個方法,一是將資料庫目錄完整備份:二是使用 MySQL 內建的 mysqldump 程式。
備份資料庫目錄
MySQL 預設的儲存目錄在 /var/lib/mysql 內容,底下會有以資料庫名稱的目錄,例如 mydb
目錄便應該是 mydb 資料庫的資料。
如果 MySQL 正在運行,請先停止 MySQL,原因是可能會有資料未完全寫入,而 MySQL 會 lock 在使用中的 DB 檔案。
01
/etc/rc.d/init.d/mysqld stop
02
cd /var/lib/mysql/
03
tar zxcf mydb_backup.tgz mydb
04
/etc/rc.d/init.d/mysqld start
以上指令會先停止 MySQL,然後把 mydb 資料庫製作一個 taz 檔的備份,並儲存到 mydb_backup.tgz。
在使用以上指令時,請根據個別系統的設定作出修改。
好了,以上就麼 3 句指令就完成備份了,如果不幸的事情發生了,資料庫發生錯誤而要復原資料,可使用以下指令:
01
/etc/rc.d/init.d/mysqld stop
02
cd /var/lib/mysql/
03
mv mydb mydb_error
04
tar zxvf mydb_backup.tgz
05
/etc/rc.d/init.d/mysqld start
以上指令是先把 /var/lib/mysql/mydb 移到 /var/lib/mysql/mydb_error,然後將原先製作的備份檔解壓到
/var/lib/mysql/mydb。
要備份 MySQL 資料庫主要分為兩個方法,一是將資料庫目錄完整備份:二是使用 MySQL 內建的 mysqldump 程式。
備份資料庫目錄
MySQL 預設的儲存目錄在 /var/lib/mysql 內容,底下會有以資料庫名稱的目錄,例如 mydb
目錄便應該是 mydb 資料庫的資料。
如果 MySQL 正在運行,請先停止 MySQL,原因是可能會有資料未完全ë
相关文档:
需注意以下三点:
1、创建数据库的时候:CREATE DATABASE `database`
CHARACTER SET 'utf8'
  ......
Each MySQL Cluster host computer running an SQL node must have
installed on it a MySQL binary. For management nodes and data
nodes, it is not necessary to install the MySQL server binary, but
management nodes require the management server daemon
......
Starting the cluster is not very difficult after it has been configured. Each cluster node process must be started separately, and on the host where it resides. The management node should be started first, followed by the data nodes, and then finally by any SQL nodes:
On the management host, issu ......
If you set it in the cnf(it may be my.ini file) you will likely need to restart the server. Optionally, that is a dynamic variable and can be SET GLOBAL or SET SESSION from the command line as well.So just do as follows.
mysql>show variables like’max_allowed_packet’;
......