mysqldump

mysql数据库的导出与导入

蹲街弑〆低调 提交于 2019-11-28 01:33:26
1、首先linux 下查看mysql相关目录       [root@op-workorder bin]# whereis mysql       mysql: /usr/bin/mysql /usr/lib64/mysql /usr/include/mysql 2、导出数据库用mysqldump命令     cd /home/work/mysql/bin # 先cd到mysql的运行路径下,再执行一下命令      1. 导出数据和表结构         ./mysqldump -uroot -p bsp > bsp.sql         mysqldump -u用户名 -p密码 数据库名 > 数据库名.sql     2. 只导出表结构         mysqldump -u用户名 -p密码 -d 数据库名 > 数据库名.sql         mysqldump -uroot -p -d dbname > dbname .sql 3、导入数据库     1、首先建空数据库         mysql>create database bsp charset utf8;     2、导入数据库(方法一)       (1)选择数据库           mysql>use bsp;       (2)导入数据(注意sql文件的路径)           mysql

Error while taking backup with mysqldump in mysql command line

旧时模样 提交于 2019-11-28 01:02:24
Hello I'm trying to take backup from mysql command line client. I'm using mysqldump to take backup with username and password. Following is the command I'm using for backing up the database. mysql> mysqldump -u username -p password databasename > backup.sql; I'm getting following error ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql dump -u username -p password fms > backup.sql' at line 1 Though the command seems to be correct, still i'm getting error. Please let me know is there

How do I dump MySQL file without Foreign Keys via command line?

依然范特西╮ 提交于 2019-11-28 00:44:57
问题 I need to export a large database without foreign keys. What is the command to do this? This is what I tried but I know this is incorrect. mysqldump -u root -p DBNAME SET FOREIGN_KEY_CHECKS = 0; | gzip > database.sql.gzip 回答1: From this SO thread: Can you automatically create a mysqldump file that doesn't enforce foreign key constraints? The mysqldump command included with MySQL 5.0.51 (and according to the change log versions since 4.1.1) does switch off foreign key checks. By default,

mysql导出表数据

送分小仙女□ 提交于 2019-11-27 23:48:04
mysqldump -upcrm -ppcrmUser*1 -h192.168.01.01 -P3399 ecrm_order0 T_EOrder>bak.sql    MYSQLdump参数详解 mysqldump备份: 复制代码 代码如下: mysqldump -u用户名 -p密码 -h主机 数据库 a -w “sql条件” –lock-all-tables > 路径 mysqldump还原: 复制代码 代码如下: mysqldump -u用户名 -p密码 -h主机 数据库 < 路径 mysqldump按条件导出: 复制代码 代码如下: mysqldump -u用户名 -p密码 -h主机 数据库 a –where “条件语句” –no-建表> 路径 mysqldump -uroot -p1234 dbname a –where “tag='88′” –no-create-info> c:\a.sql mysqldump按条件导入: 复制代码 代码如下: mysqldump -u用户名 -p密码 -h主机 数据库 < 路径 案例: 复制代码 代码如下: mysql -uroot -p1234 db1 < c:\a.txt mysqldump导出表: 复制代码 代码如下: mysqldump -u用户名 -p密码 -h主机 数据库 表 案例:mysqldump -uroot -p

mysql导出数据库几种方法

风格不统一 提交于 2019-11-27 22:11:26
mysql教程导出数据库教程几种方法 方法一 cmd 到mysql bin目录下用 如下命令 mysqldump --opt -h192.168.0.156 -uusername -ppassword --skip-lock-tables databasename>database.sql 把ip改成localhost就可以的 如果装了navicate那就更简单了 先连接上数据库,选中数据库 再选择转储sql 就好了 方法二 进入cmd (注意在os cmd中 而不是在mysql中) =================== 1.导出数据库(sql脚本) mysqldump -u 用户名 -p 数据库名 > 导出的文件名   mysqldump -u root -p db_name > test_db.sql   2.mysql导出数据库一个表   mysqldump -u 用户名 -p 数据库名 表名> 导出的文件名   mysqldump -u wcnc -p test_db users> test_users.sql (结尾没有分号) 方法三 启动mysql服务 /etc/init.d/mysql start 导出整个数据库 mysqldump dbname > c:mydb.sql -u root -p 导入数据库 source mydb.sql mysql -u用户名 -p

Can you automatically create a mysqldump file that doesn't enforce foreign key constraints?

你。 提交于 2019-11-27 20:22:31
When I run a mysqldump command on my database and then try to import it, it fails as it attempts to create the tables alphabetically, even though they may have a foreign key that references a table later in the file. There doesn't appear to be anything in the documentation and I've found answers like this that say to update the file after it's created to include: set FOREIGN_KEY_CHECKS = 0; ...original mysqldump file contents... set FOREIGN_KEY_CHECKS = 1; Is there no way to automatically set those lines or export the tables in the necessary order (without having to manually specify all table

How to deal with enormous line lengths created by mysqldump

天大地大妈咪最大 提交于 2019-11-27 17:23:13
I'm using mysqldump in a cron job to backup a database with over 2 million rows. It creates a text file which can be used to restore the datalog from the command line. I thought it would be useful to edit the dump before a restore as a quick way of changing values and table or column names - at least until I learn more and become confident about doing it with ALTER and UPDATE. Editing large text files does not bother me, but I was surprised to find that in a 250 megabyte dump of my database, there were only about 300 lines . Each line was something like 800k characters long. Is there another

mysql备份

廉价感情. 提交于 2019-11-27 17:09:43
MySQL备份: 必须是在没有登录之前使用 注意:   1.执行lock是因为需要对表进行枷锁,防止别的线程操作   2.mysqldump,一次dump的数据是1000条 mysqldump -uroot -p > D:/a.sql 导入和导出一对:   mysqldump -uroot -p db3>D:/db3.sql 恢复表的数据: 1.create database db3; 2.exit 3.mysql - uroot -p xxx < D:/db3.sql source D:/db2.sql; 第二种: -B : 会自动创建数据库,并且自动使用此数据库 mysqldump -uroot -p -B db2 > D:/db2.sql 备份mysql数据库的表结构(不包含数据) mysqldump -uroot -p -d test > D:/c.sql 参数 -t 的作用就是备份数据库的表数据(不要包含表结构) mysqldump -uroot -p密码 -t test 来源: https://www.cnblogs.com/xinfan1/p/11054908.html

How can I slow down a MySQL dump as to not affect current load on the server?

不羁岁月 提交于 2019-11-27 17:06:26
While doing a MySQL dump is easy enough, I have a live dedicated MySQL server that I am wanting to setup replication on. To do this, I need dumps of the databases to import to my replication slave. The issue comes when I do the dumps, MySQL goes full force at it and ties up resources to the sites that connecting to it. I am wondering if there is a way to limit the dump queries to a low priority state to which preference is given to live connections? The idea being that the load from external sites is not affected by the effort of MySQL to do a full dump... CA3LE I have very large databases

How to skip row when importing bad MySQL dump

只愿长相守 提交于 2019-11-27 15:30:42
问题 Given bad mysqldump that causes error on import: namtar backups # mysql -p < 2010-12-01.sql Enter password: ERROR 1062 (23000) at line 8020: Duplicate entry 'l�he?' for key 'wrd_txt' Is there an easy way to tell import to just skip given row and continue? (Yes, I know I can manually edit the file or parse output, but it's not very convinient) 回答1: If you can make the dump again you could add --insert-ignore to the command-line when dumping. Or you can try using the mysqlimport command with -