l 基本使用:
cmd>mysqldump -u root -p 数据库 > 数据存放路径
恢复数据库,进入到mysql管理控制台
(1) mysql_query('set names utf8')
(2) 如果我们在备份一个数据库时,也带上 -B参数,更好,在恢复数据库时,不需要再创建空数据库即;
cmd>mysqldump -u root -p -B 数据库 > 数据存放路径
l 备份数据库需要注意的地方
(1) 如果我们只希望备份数据库的某几张表.
cmd>mysqldump -u root -p 数据库名 表名1 表名2 > d:/tnblog3.bak
(2) 如何恢复指定的表
mysql>source 备份的文件全路径
注意: 在使用source 恢复数据时,保证你use 对应的数据库.
(3) 如何同时备份多个数据库
mysqldump –u 用户名 –p密码 -B 数据库1 数据库2 .. > d:\文件名.sql
演示:
(4) 同时恢复多个数据库
l 课堂练习题
1.1 数据库的修改操作
l 基本语法
说明:
(1) 对数据库的修改主要指的是修改它的字符集(character set),校验规则(collate)和存储引擎(engine)
(2) 案例说明: 查看服务器中的数据库,并把其中某一个库的字符集修改为utf8
对表修改存储引擎