mysqldump

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

冷暖自知 提交于 2019-11-26 22:50:35
问题 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

How can I access the MySQL command line with XAMPP for Windows?

六月ゝ 毕业季﹏ 提交于 2019-11-26 21:20:37
How can I access the MySQL command line with XAMPP for Windows? Your MySQL binaries should be somewhere under your XAMPP folder. Look for a /bin folder, and you'll find the mysql.exe client around. Let's assume it is in c:\xampp\mysql\bin, then you should fireup a command prompt in this folder. That means, fire up "cmd", and type: cd c:\xampp\mysql\bin mysql.exe -u root --password If you want to use mysqldump.exe, you should also find it there. Log into your mysql server, and start typing your commands. Hope it helps... On the Mac, or at least on my Mac using a default install, I accessed it

Skip certain tables with mysqldump

痴心易碎 提交于 2019-11-26 18:41:40
问题 Is there a way to restrict certain tables from the mysqldump command? For example, I'd use the following syntax to dump only table1 and table2: mysqldump -u username -p database table1 table2 > database.sql But is there a similar way to dump all the tables except table1 and table2? I haven't found anything in the mysqldump documentation, so is brute-force (specifying all the table names) the only way to go? 回答1: You can use the --ignore-table option. So you could do mysqldump -u USERNAME

How can I get rid of these comments in a MySQL dump?

独自空忆成欢 提交于 2019-11-26 17:34:33
I'm trying to create a simple structure only dump of my database. Using mysqldump gives me a result like: /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; DROP TABLE IF EXISTS `foo`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; No matter what I try, I just can't seem to get rid of those comments. I'm

mysqldump with db in a separate file

情到浓时终转凉″ 提交于 2019-11-26 15:48:15
问题 I'm writing a single line command that backups all databases into their respective names instead using of dumping all in one sql. Eg: db1 get saved to db1.sql and db2 gets saved to db2.sql So far, I'd gathered the following commands to retrieve all databases. mysql -uuname -ppwd -e 'show databases' | grep -v 'Database' I'm planning to pipe it with awk to do something like awk '{mysqldump -uuname -ppwd $1 > $1.sql}' But that doesn't work. I'm new to bash, so I could be wrong in my thinking.

Mysqldump launched by cron and password security

泪湿孤枕 提交于 2019-11-26 13:01:18
问题 I wrote a script to backup my MySQL databases using: mysqldump --opt --all-databases -u user -pmypassword > myDump.sql A cron launches it every night and scp the result to another server. mypassword appears in clear in my script, everyone can see it with the appropriate rights. I have been told about /proc issues too (where the cmd run can be seen). MySQL documentation says: Specifying a password on the command line should be considered insecure. See Section 7.6, \"Keeping Your Password

Mysql的冷备热备(数据备份)

左心房为你撑大大i 提交于 2019-11-26 12:27:28
冷备可以是mysql工具 msqldump。 mysqldump -u username -p dbname table1 table2 ... -> BackupName.sql dbname 数据库名称 table1 table2 是表名称 BackupName.sql 备份保存的相对路径的sql文件 执行下面命令。 mysqldump -u homestead -psecret homestead > /home/vagrant/backup.sql 然后输入密码然后备份成功。 mysqldump -u homestead -psecret 在终端执行会出现(Warning: Using a password on the command line interface can be insecure.)的情况,我们在mysq配置文件 /etc/mysql/conf.d/mysqldump.cnf。 加上配置,这样执行mysqldump 就不用 -u homestead -psecret user=homestead password=secret 当然我们可以写个简单的shell脚本执行备份命令,然后使用corntab或者supervisor定时跑这个shell脚本。 #!/bin/sh mkdir -p -m 777 /home/vagrant/backup

#1071 - Specified key was too long; max key length is 1000 bytes

↘锁芯ラ 提交于 2019-11-26 12:07:52
I know questions with this title have been answered before, but please do read on. I've read thoroughly all the other questions/answers on this error before posting. I am getting the above error for the following query: CREATE TABLE IF NOT EXISTS `pds_core_menu_items` ( `menu_id` varchar(32) NOT NULL, `parent_menu_id` int(32) unsigned DEFAULT NULL, `menu_name` varchar(255) DEFAULT NULL, `menu_link` varchar(255) DEFAULT NULL, `plugin` varchar(255) DEFAULT NULL, `menu_type` int(1) DEFAULT NULL, `extend` varchar(255) DEFAULT NULL, `new_window` int(1) DEFAULT NULL, `rank` int(100) DEFAULT NULL,

dump all mysql tables into separate files automagically?

十年热恋 提交于 2019-11-26 10:24:50
问题 I\'d like to get dumps of each mysql table into separate files. The manual indicates that the syntax for this is mysqldump [options] db_name [tbl_name ...] Which indicates that you know the table names before hand. I could set up the script that knows each table name now, but say I add a new table down the road and forget to update the dump script. Then I\'m missing dumps for one or more table. Is there a way to automagically dump each existing table into a separate file? Or am I going to

script to convert mysql dump sql file into format that can be imported into sqlite3 db

我是研究僧i 提交于 2019-11-26 09:29:26
问题 I have an export SQL file containing tables and data from MySQL and I want to import it into a Sqlite 3 DB. What is the best way to do that? Just importing the file via the sqlite3 tool doesn\'t work. 回答1: This shell script help you #!/bin/sh if [ "x$1" == "x" ]; then echo "Usage: $0 <dumpname>" exit fi cat $1 | grep -v ' KEY "' | grep -v ' UNIQUE KEY "' | grep -v ' PRIMARY KEY ' | sed '/^SET/d' | sed 's/ unsigned / /g' | sed 's/ auto_increment/ primary key autoincrement/g' | sed 's/ smallint