MySQL数据库备份和恢复
1、如果您没有修改MySQL的root用户的密码,可在本机登录CactiEZ中文版V10或以SSH方式登录CactiEZ中文版V10。
未修改密码备份MySQL数据库方法:
# mysqldump cacti > cacti.20110330.sql# lscacti.20110330.sql说明:mysqldump是MySQL数据库导出命令,cacti是数据库名,cacti.20110330.sql是导出后的文件名。已修改密码备份MySQL数据库方法:
# mysqldump -u root -p cacti > cacti.20110330.sqlEnter password:# ls cacti.20110330.sqlcacti.20110330.sql说明:-u表示指定用户名,-p表示该用户需要使用密码。输入回车后,在Enter password:后输入root用户的密码,输入时不显示密码或星号。PS:比如Cacti的数据库备份
1、数据库备份:
mysqldump -u root -p cacti > 2017.2.13.sql (密码:cactifansdb 默认数据库密码)2、图片备份tar -cvf rra-2017.2.9.tar /var/www/html/rra (图片压缩)
2、MySQL数据库恢复方法未修改密码恢复MySQL数据库方法:# mysql cacti < cacti.20110330.sql如果有任何报错,请按以下步骤登录MySQL,删除原有库,新建库,再导入:# mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 83Server version: 5.1.47 Source distributionCopyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,and you are welcome to modify and redistribute it under the GPL v2 licenseType 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> drop database cacti;
Query OK, 66 rows affected (0.12 sec)mysql> create database cacti;
Query OK, 1 row affected (0.00 sec)mysql> exit
Bye# mysql cacti < cacti.20110330.sql已修改密码恢复MySQL数据库方法:
# mysql -u root -p cacti < cacti.20110330.sql Enter password:如果有任何报错,请按以下步骤登录MySQL,删除原有库,新建库,再导入:# mysql -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 83Server version: 5.1.47 Source distributionCopyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,and you are welcome to modify and redistribute it under the GPL v2 licenseType 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> drop database cacti;
Query OK, 66 rows affected (0.12 sec)mysql> create database cacti;
Query OK, 1 row affected (0.00 sec)mysql> exit
Bye# mysql cacti < cacti.20110330.sqlPS:Cacti数据库还原
1、数据库还原
mysql cacti < 2017.2.13.sql
2、图片还原
cp -rv ./root/rra-2017.2.9.tar /var/www/html/rra