mysqldump

How To Avoid Repair With Keycache?

末鹿安然 提交于 2019-11-27 09:52:11
问题 I have had some experience with optimizing the my.cnf file but my database has around 4 million records (MyISAM). I am trying to restore from a mysqldump but every time I do I eventually get the dreaded "Repair With Keycache", that may take days. Is there any way to get past this and let it roll as "Repair By Sorting"? I have 2GB RAM, Dual Cores, lots of extra hard-drive space. Snip out of my.cnf: set-variable = max_connections=650 set-variable = key_buffer=256M set-variable = myisam_sort

MYSQL Dump only certain rows

亡梦爱人 提交于 2019-11-27 09:49:31
问题 I am trying to do a mysql dump of a few rows in my database. I can then use the dump to upload those few rows into another database. The code I have is working, but it dumps everything. How can I get mysqldump to only dump certain rows of a table? Here is my code: mysqldump --opt --user=username --password=password lmhprogram myResumes --where=date_pulled='2011-05-23' > test.sql 回答1: Just fix your --where option. It should be a valid SQL WHERE clause, like: --where="date_pulled='2011-05-23'"

Clone MySQL database

拥有回忆 提交于 2019-11-27 09:20:59
问题 I have database on a server with 120 tables. I want to clone the whole database with a new db name and the copied data. Is there an efficient way to do this? 回答1: $ mysqldump yourFirstDatabase -u user -ppassword > yourDatabase.sql $ mysql yourSecondDatabase -u user -ppassword < yourDatabase.sql 回答2: mysqldump -u <user> --password=<password> <DATABASE_NAME> | mysql -u <user> --password=<password> -h <hostname> <DATABASE_NAME_NEW> 回答3: Like accepted answer but without .sql files: mysqldump

How to use MySQL dump from a remote machine

与世无争的帅哥 提交于 2019-11-27 09:16:42
问题 How can I backup a mysql database which is running on a remote server, I need to store the back up file in the local pc. 回答1: Try it with Mysqldump #mysqldump --host=the.remotedatabase.com -u yourusername -p yourdatabasename > /User/backups/adump.sql 回答2: Have you got access to SSH? You can use this command in shell to backup an entire database: mysqldump -u [username] -p[password] [databasename] > [filename.sql] This is actually one command followed by the > operator, which says, "take the

Where I can find a list of “mysqldump” exit codes?

孤者浪人 提交于 2019-11-27 09:15:50
I know that exit code = 0 means No error . I got exit code = 2 . What does it means ? Where I can see the complete list of mysqldump exit codes ? Taken from client/mysqldump.c in MySQL 5.1.59: #define EX_USAGE 1 #define EX_MYSQLERR 2 #define EX_CONSCHECK 3 #define EX_EOM 4 #define EX_EOF 5 /* ferror for output file was got */ #define EX_ILLEGAL_TABLE 6 Skimming through the source, EX_MYSQLERR seems to be used mostly for errors from the server, but also in case malloc fails. CONSCHECK seems to stand for consistency checks. EX_EOM is returned for some _alloc calls too - "End Of Memory"?

数据库的备份,迁移

你离开我真会死。 提交于 2019-11-27 07:32:28
08.14自我总结 数据库的备份 一数据库的备份 1.单库备份 mysqldump -uroot -p123 db1 > db1.sql #库名 mysqldump -uroot -p123 db1 table1 table2 > db1-table1-table2.sql #库名 表名 2.多库备份 mysqldump -uroot -p123 --databases db1 db2 mysql db3 > db1_db2_mysql_db3.sql 3.备份所有库 mysqldump -uroot -p123 --all-databases > all.sql 二.备份恢复 1.退出数据库后 mysql -u -p < filename.sql; 2.在数据库内 创建空数据库 选择数据库 然后使用source filename; 来进行还原 例如 use db1; source /root/db1.sql 三.数据库迁移 务必保证在相同版本之间迁移 # mysqldump -h 源IP -uroot -p123 --databases db1 | mysql -h 目标IP -uroot -p456 四.备份高阶 1.常用参数 -B:表示的是指定多个库,增加了建库语句和use数据库的语句。 -compact:去掉注释,适合调试输出,不适合在生产环境使用。 -A:

How to restore a MySQL database backup using Java

ぐ巨炮叔叔 提交于 2019-11-27 07:28:24
问题 I was able to create a backup of my current mysql database as .SQL file using the mysqldump.exe with the help of the following java code. Process runProcess = Runtime.getRuntime().exec("C:\\SCM Files\\SQL Backup\\mysqldump.exe -uroot -p123 rr -r\"C:\\SCM Files\\SQL Backup\\RR.sql"); Now I want to restore this same .SQL Backup file to mysql database using java code similar to above on the event of a button clicked. Thanks a lot :) So now I tried this ; Process runProcess = Runtime.getRuntime()

Mysqldump launched by cron and password security

99封情书 提交于 2019-11-27 07:03:55
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 Secure". I have not found this magic 7.6 sections anywhere. What is the good practice to deal with automatic

mysqldump via PHP

♀尐吖头ヾ 提交于 2019-11-27 06:54:47
问题 I have a PHP script that gets passed the MySQL connection details of a remote server and I want it to execute a mysqldump command. To do this I'm using the php exec() function: <?php exec("/usr/bin/mysqldump -u mysql-user -h 123.145.167.189 -pmysql-pass database_name > /path-to-export/file.sql", $output); ?> When the right login details are passed to it, it'll work absolutely fine. However, I'm having trouble checking if it executes as expected and if it doesn't finding out why not. The

Cloning a MySQL database on the same MySql instance

狂风中的少年 提交于 2019-11-27 05:58:05
I would like to write a script which copies my current database sitedb1 to sitedb2 on the same mysql database instance. I know I can dump the sitedb1 to a sql script: mysqldump -u root -p sitedb1 >~/db_name.sql and then import it to sitedb2 . Is there an easier way, without dumping the first database to a sql file? Greg As the manual says in Copying Databases you can pipe the dump directly into the mysql client: mysqldump db_name | mysql new_db_name If you're using MyISAM you could copy the files, but I wouldn't recommend it. It's a bit dodgy. Integrated from various good other answers Both