mysqldump

MYSQL数据库的导出和导入

人盡茶涼 提交于 2019-11-30 21:10:11
一、连接服务器查看数据库 使用连接工具(xshell6等)连接到数据库所在服务器,执行命令查询需要导出的数据库 1.输入数据库管理员账号密码进入控制台:mysql -uroot -p123456 #root为管理员账号,123456为密码 2.执行命令:show databases; 查询数据库 二、导出 1 使用MySQL自带的mysqldump的命令进行导出:mysqldump -uroot -p123456 -R -E gd_base >/u01/gd_base.sql 2 执行导出命令后,在服务器对应目录下可找到导出的sql文件 3 导出命令详解 MySQL使用MySQL自带的mysqldump的命令进行导出时,可进行全库导出和单个数据库导出。相关命令解析如下: 全库导出:mysqldump -u用户名 -p密码 -R -E 数据库1 数据库2... > 保存路径/文件名.sql 单个数据库导出:mysqldump -u用户名 -p密码 -R -E 数据库 > 保存路径/文件名.sql(红色字体替换成对应的数据库信息;用户名:一般指“root”;密码:用户名对应的密码,数据库:需要导出的数据库名称,多数据库则用空格隔开;保存路径/文件名:导出的路径和生成的文件名;-R -E:导出所有(结构&数据&存储过程&函数&事件&触发器)) 三、导入 1

How to copy a database with mysqldump and mysql in Python?

▼魔方 西西 提交于 2019-11-30 19:59:50
问题 I am writing a simple Python script to copy a MySQL database. I am attempting to copy the database based on the following SO questions and their answers: "Copy/duplicate database without using mysqldump", "python subprocess and mysqldump" and "Python subprocess, mysqldump and pipes". However, my script does not work for some reason I cannot see as the tables and the data do not appear in my new database. I can see from my output that the mysqldump works correctly (I see a "Dump completed on..

Mysql ERROR: ASCII '\\0' while importing sql file on linux server

こ雲淡風輕ζ 提交于 2019-11-30 19:13:58
I am getting following error while importing sql file ERROR: ASCII '\0' appeared in the statement, but this is not allowed unless option --binary-mode is enabled and mysql is run in non-interactive mode. Set --binary-mode to 1 if ASCII '\0' is expected. Query: ''. HELP NEEDED...!! Eric BELLION Try something like : mysql -u root -p -h localhost -D database --binary-mode -o < dump.sql and make sure your sql file is not zipped . I encountered this problem,the sql file was in a valid ISCII format, I solved as the following: 1- in shell use file command to detect type of data contained in the dump

mysql数据备份

自古美人都是妖i 提交于 2019-11-30 18:56:06
导出整个数据库结构和数据 mysqldump -h localhost -uroot -p123456 database > dump.sql 导出单个数据表结构和数据 mysqldump -h localhost -uroot -p123456 database table > dump.sql 导出整个数据库结构(不包含数据) mysqldump -h localhost -uroot -p123456 -d database > dump.sql 导出单个数据表结构(不包含数据) mysqldump -h localhost -uroot -p123456 -d database table > dump.sql #### 总是找不到随笔记一下 来源: https://www.cnblogs.com/jinghu/p/11635978.html

mysql增量备份及恢复解决方案

那年仲夏 提交于 2019-11-30 17:27:59
前言 操作系统崩溃、电源故障、文件系统崩溃和硬件故障等异常状况都可能导致我们正在使用的数据库出现故障而产生数据库中数据不一致的情况。为了保证数据库使用安全,必须定期备份数据库;数据库备份可以分为:完全备份、日志备份、增量备份和文件备份。对于一个大型数据库,频繁执行完全备份可能会需要太多的时间,而且完全备份经常会多次备份一些没有更新过的数据,会造成资源浪费。现在最常用的数据库备份策略是在完全备份的基础上进行较频繁的增量备份。例如,我们可以在数据库使用较少的时段每周进行一次完全备份,然后每天进行一次增量备份,备份下这段时间中可能修改数据库内容的操作,以便在发生文件系统故障、硬件问题等问题导致数据库发生灾难性崩溃的时候利用备份数据进行数据库的恢复。 u 技术分析 MySQL数据库对上述几种导致数据库崩溃的故障都给出了很好的解决办法以保证数据的一致性。 对于操作系统崩溃和电源故障导致的MySQL数据库崩溃,使用MySQL提供的内置方法,在大多数情况下都可以非常有效的恢复:如果我们使用的是MyISAM数据库,可以使用 REPAIR TABLE 或者myisamchk –r 对可能损毁的数据库表进行修补;如果我们使用的是InnoDB,则InnoDB会自动找到挂起的提交了的或未提交的事务列表,并自动回滚未提交的事务和刷新已提交的事务。 如果我们使用前面的方面未能正确恢复被损害的数据

How do I see the differences between 2 MySQL dumps?

陌路散爱 提交于 2019-11-30 13:10:26
问题 I have 2 MySQL dump files. I want to find the table data difference between 2 tables. 回答1: Use a DIFF tool - here are some graphical ones (both are free): KDIFF winmerge 回答2: run mysqldump with "--skip-opt" to get the 2 dumps files i.e: mysqldump --skip-opt -u $MY_USER -p$MY_PASS mydb1 > /tmp/dump1.sql mysqldump --skip-opt -u $MY_USER -p$MY_PASS mydb2 > /tmp/dump2.sql compare using these diff options: diff -y --suppress-common-lines /tmp/dump1 /tmp/dump2 回答3: In order to compare 2 mysql diffs

Where does WAMP server store database files

家住魔仙堡 提交于 2019-11-30 12:28:00
问题 This question was migrated from Super User because it can be answered on Stack Overflow. Migrated 8 years ago . My hard-drive has encountered some problems and I am unable to boot Windows with it. I am able to view the drive's contents by connecting it to another PC as an external drive. On the culprit drive I was running a local WAMP server for dev purposes and I'm looking to save the mySQL databases from it. I can see my wamp directory at E:\wamp . Is it possible to start up the server from

mysqldump from a query

牧云@^-^@ 提交于 2019-11-30 12:02:09
How can I make a mysql dump for table from a query? I need something like this.. mysqldump -uroot -pxxxx mydb "select * from table where name='1';" > /tmp/a Thanks. mysqldump has a --where parameter: Manual Dump only rows selected by the given WHERE condition. Quotes around the condition are mandatory if it contains spaces or other characters that are special to your command interpreter. Examples: --where="user='jimf'" -w"userid>1" -w"userid<1" I don't know what they use, but phpMyAdmin can do this too, Just make the query, select all rows and choose the "export" button to the bottom. Another

Batch-file for mysqldump to backup each database into a separate file

[亡魂溺海] 提交于 2019-11-30 11:30:09
问题 Trying to create a batch (cmd) file for backing up each database into a separate file. Databases are created/deleted often, so batch file needs to grab current db names everytime it runs and backup each one of them. Here is how I want it to be: mysql -e "show databases" -u root --password=1234 mysqldump %dbname% -u root --password=1234 > S:\Backup\MySQL\%dbname%.sql Is it possible to do in a batch file? Please help. Thanks. 回答1: This can be run directly in cmd (I wrapped the line but it

MySQL Error 2006 (HY000) at line 406: MySQL server has gone away

99封情书 提交于 2019-11-30 11:07:48
I have a MYSQL dump from a database that I am trying to move to a new db server. When I try to import my sql dump, I receive the following error: MySQL Error 2006 (HY000) at line 406: MySQL server has gone away I googled the problem and most people fixed the problem by changing the value of wait_timeout. However, my current value is set to 28800 (8 hours) and the error appears in less than 8 seconds when I run the import. I also tried setting the value of max_allowed_packet to 1073741824 but that also did not fix the problem. Looking through the mysql dump, there are quite a few blob columns