mysqldump

MySQL 备份数据那点事

有些话、适合烂在心里 提交于 2019-12-04 11:02:03
mysqldump 什么是 mysqldump ? mysqldump 是 MySQL 用于执行逻辑备份的一款工具,可以根据原始数据库对象以及表的定义和数据来生成一系列可以被执行的 SQL 语句。 通常我们用它作为备份或者迁移数据。 mysqldump 命令还可以输出成 CSV 文件,其他边界的文本或者 XML 格式。 如何使用 mysqldump? 导出整个数据库(包含数据) mysqldump -u username -p dbname > dbname.sql 导出数据库结构 mysqldump -u username -p -d dbname > dbname.sql 导出数据库中的某张表 mysqldump -u username -p dbname tablename > tablename.sql 导出数据库中的某张表结构 mysqldump -u username -p -d dbname tablename > tablename.sql 导入数据 mysql -u username -p dbname < dbname.sql 也可以在 msyql CLI 中导入: source /home/dbname.sql mysqldump 的常见参数: --single-transaction : 当设置此参数时,会将事务隔离模式设置为 REPEATABLE_READ

PhpMyAdmin export does not include PRIMARY KEY as mysqldump

此生再无相见时 提交于 2019-12-04 10:52:46
问题 Export of the struture of the same table with PhpMyAdmin: `DROP TABLE IF EXISTS `test_apprentis`; CREATE TABLE IF NOT EXISTS `test_apprentis` ( `a_id` smallint(10) NOT NULL, `a_promo_id` smallint(11) NOT NULL, `a_cursus` smallint(10) DEFAULT NULL ) ENGINE=MyISAM AUTO_INCREMENT=3665 DEFAULT CHARSET=utf8;` Export with mysqldump: DROP TABLE IF EXISTS `test_apprentis`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `test

Importing 1GO SQL File => ERROR 2013 (HY000) at line 23: Lost connection to MySQL server during query

我是研究僧i 提交于 2019-12-04 10:13:40
问题 Ive got to import 1go of sql data, i raised up the max_allowed_packet to 1100M to be sure. So i use : My query mysql -u root -p -D mainbase < GeoPC_WO.sql But 1 minute later it stops during the process and i get this error : **ERROR 2013 (HY000) at line 23: Lost connection to MySQL server during query **Lost connection to MySQL server during query**** 回答1: Possible that you have some large insert statements that are bigger than you max size. Check your /etc/mysql/my.cnf file or wherever it is

mysqldump partial database

与世无争的帅哥 提交于 2019-12-04 10:02:08
I recently decided to switch the company through which i get my hosting, so to move my old db into my new db, i have been trying to run this: mysqldump --host=ipaddress --user=username --password=password db_name table_name | mysql -u username -ppassword -h new_url new_db_name and this seemed to be working fine.. but because my database is so freaking massive, i would get time out errors in the middle of my tables. So i was wondering if there was any easy way to do a mysqldump on just part of my table. I would assume the work flow will look something like this: create temp_table move rows from

The faster method to move redis data to MySQL

瘦欲@ 提交于 2019-12-04 09:41:32
问题 We have big shopping and product dealing system. We have faced lots problem with MySQL so after few r&D we planned to use Redis and we start integrating Redis in our system. Following this previously directly hitting the database now we have moved the Redis system User shopping cart details Affiliates clicks tracking records We have product dealing user data. other site stats. I am not only storing the data in Redis system i have written crons which moves Redis data in MySQL data at time

Can I merge two databases into one in Mysql if they both have the same schema?

眉间皱痕 提交于 2019-12-04 09:35:01
问题 I have two databases in MySQL that already have data. they have exactly the same schema. I would like to merge those two databases into one only. I tried: mysqldump -u root -p --databases database1 database2 database3 > database1_database2_da However, when I try to open database1_database2_da , I only end up with data from one of the database, but not all of them. I also want to mention that the two databases have their records starting at 1, since they are automatically generated. Do you

how to add date and time with backupfile name using mysqldump from command prompt and to define the path of backupfile

为君一笑 提交于 2019-12-04 09:23:01
Im using this command for backup from mysqldump mysqldump -uroot -ptrackerdb) --alldatabases >test.sql Now i want to add date-time with my backup file like current date and time e.g test_25July2013_13:00 For this i add test_ date +%Y-%m-%d_%H-%M-%S .sql in file name but it gives error 'Couldn't find table': date +%Y-%m-%d_%H-%M-%S` What I'm doing wrong here? jaczes I'm using that: LINUX mysqldump -u <user> -p <database> | bzip2 -c > <backup>$(date +%Y-%m-%d-%H.%M.%S).sql.bz2 WINDOWS (googled it, because i have been using LIN only) @echo off cls echo Date format = %date% echo dd = %date:~0,2%

mysqldump problem with case sensitivity? Win->linux

旧城冷巷雨未停 提交于 2019-12-04 08:31:24
When i dump a table with uppercase letters using mysqldump it comes out as lower case in my > dump.sql file. I found a report here in 2006, almost 4 years old http://bugs.mysql.com/bug.php?id=19967 A solution here suggest making linux insensitive. I rather not if possible. Whats the easiest way to copy a win32 db into linux? Today I've had to make it so. I already have windows db in lower case and need to import to linux db with case sensitive table names, so the play with lowecase_table_names option in not an option :) It looks that 'show tables' displays appropriately sorted table names and

命令行模式下备份、还原 MySQL 数据库的语句小结

随声附和 提交于 2019-12-04 08:09:25
为了安全起见,需要经常对数据库作备份,或者还原,学会在命令行模式下备份、还原数据库,还是很有必要 为了安全起见,需要经常对数据库作备份,或者还原。对于 MySQL 而言,最方便的方法可能就是用 phpMyAdmin 的导出、导入功能了,但如果你的数据库体积比较大,作为 Web 应用的 phpMyAdmin 可能会遭遇“超时”而操作失败。所以,学会在命令行模式下备份、还原数据库,还是很有必要的。 1、备份数据库 在 Linux 命令行模式下备份 MySQL 数据库,用的是 mysqldump 命令: mysqldump -u mysqluser -p test_db 对以上命令稍作解释: •-u 意味着你要指定一个 MySQL 用户名来连接数据库服务,如上面的 mysqluser 即为 MySQL用户名。 •-p 则意味着你需要有一个有效的,与以上用户名对应的密码。 •最后一个参数则是需要备份的那个数据库的名称:test_db 如果直接执行以上命令,紧接着就会提示需要输入 MySQL 密码,数据密码后,它会直接将备份出来的 SQL 脚本显示在屏幕上,这当然不是我们想要的结果。我们需要把数据库备份成一个文件,可用以下命令: mysqldump -u mysqluser -p test_db > test_db.sql 这样,就会在当前目录下备份出一个名为test_db.sql的文件。

How to use mysqlimport to read in result of mysqldump --databases

淺唱寂寞╮ 提交于 2019-12-04 07:53:36
问题 I have successfully dumped an entire MySQL database using mysqldump --databases generating a nice .txt file. However, I can't see how to read the whole file back into MySQL in one go; mysqlimport seems to want just one table at a time. 回答1: When you've generated some file (say db-dump.sql ) with mysqldump , you can import it to your other database with the mysql command : mysql --user=XXX --password=XXX --host=YOUR_HOST DATABASE_NAME < db-dump.sql And, if you don't want the password to appear