mysqldump

mysqldump使用

北城以北 提交于 2019-11-27 05:21:13
一、使用mysqldump 备份数据库 1.1备份指定的多个数据库。 mysql> mysqldump -uroot -ppassword --databases choose test > backup.sql 1.2备份所有的数据库 mysql> mysqldump -uroot -ppassword --all-databases choose test > backup.sql 1.3备份指定数据库中的某些表 mysqldump -uroot -ppassword databasename table1 table2 table3 > table.sql mysqldump 完整的参数 mysqldump -u USER_NAME -p PASSWORD [其他选项] DB [其他数据库库表] default-character-set: 设置字符集 single-transaction : 将导出设置成事务 no-data : 导出的SQL脚本中,将只包含创建表的create 语句。 add-drop-table :导出的脚本中,包含 drop table if exists routines:导出存储过程及函数 events:导出事件 triggers:导出触发器 二、导入mysqldump 的数据文件 2.1在mysql终端下使用source命令 mysql>

Mysqldump only tables with certain prefix / Mysqldump wildcards?

时间秒杀一切 提交于 2019-11-27 05:01:00
问题 I have this huge, messy database I am cleaning up. It houses 500+ tables, which is the result of combining Magento Enterprise with Joomla in one single DB. To make things worse, there is a set of 70+ Joomla tables that are not in use at all. These are all prefixed with bak_ . Just deleting these bak_ tables will be easy, but I want to 'bak' them up first (see what I did there?). In my mind I can picture a command like this: mysqldump -u username -p mydatabase bak_* But this doesn't work. What

I want to copy table contained from one database and insert onto another database table

北战南征 提交于 2019-11-27 04:58:24
问题 I want to copy a table's schema as well as the data within that table to another database table in another database on a live server. How could I do this? 回答1: If you want to copy a table from one Database to another database , You can simply do as below. CREATE TABLE db2.table LIKE db1.table; INSERT INTO db2.table SELECT * FROM db1.table; 回答2: or just CREATE TABLE db2.table SELECT * FROM db1.table in MySQL 5 回答3: CREATE TABLE db2.table_new AS SELECT * FROM db1.table_old 回答4: If you just want

mysqldump - Export structure only without autoincrement

て烟熏妆下的殇ゞ 提交于 2019-11-27 04:13:11
问题 I have a MySQL database and I am trying to find a way to export its structure only, without the auto increment values. mysqldump --no-data would almost do the job, but it keeps the auto_increment values. Is there any way to do it without using PHPMyAdmin (that I know it can do it)? 回答1: You can do this : mysqldump -u root -p -h <db-host> --opt <db-name> -d --single-transaction | sed 's/ AUTO_INCREMENT=[0-9]*\b//' > <filename>.sql As mentioned by others, If you want sed to works properly, add

dump all mysql tables into separate files automagically?

对着背影说爱祢 提交于 2019-11-27 03:10:33
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 have to do some script-fu; query the database, get all the table names, and dump them by name. If I go the

mysqldump doesn't work in crontab

亡梦爱人 提交于 2019-11-27 01:49:59
问题 I'm trying to add a cronjob in the crontab (ubuntu server) that backups the mysql db. Executing the script in the terminal as root works well, but inserted in the crontab nothing happens. I've tried to run it each minutes but no files appears in the folder /var/db_backups. (Other cronjobs work well) Here is the cronjob: * * * * * mysqldump -u root -pHERE THERE IS MY PASSWORD --all-databases | gzip > /var/db_backups/database_`date +%d%m%y`.sql.gz what can be the problem? 回答1: You need to

Enable binary mode while restoring a Database from an SQL dump

非 Y 不嫁゛ 提交于 2019-11-27 00:32:46
问题 I am extremely new to MySQL and am running it on Windows. I am trying to restore a Database from a dumpfile in MySQL, but I get the following error: $ >mysql -u root -p -h localhost -D database -o < dump.sql 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: 'SQLite format 3'. I have tried putting --binary-mode in the ini file but it still

Restore the mysql database from .frm files

烈酒焚心 提交于 2019-11-27 00:05:36
I have dumped all my tables everyweek to got the backup. But later I understand that it is only storing the .frm file of the table. It is not showing .MYD and .MYI files of a table. So I have only my .frm file of the database with me and also mydatabase is innodb. So can I get my database with data in the database? user359187 Yes this is possible. It is not enough you just copy the .frm files to the to the databse folder but you also need to copy the ib_logfiles and ibdata file into your data folder. I have just copy the .frm files and copy those files and just restart the server and my

Minimum GRANTs needed by mysqldump for dumping a full schema? (TRIGGERs are missing!!)

白昼怎懂夜的黑 提交于 2019-11-27 00:05:15
问题 I have a MySQL user called dump with the following perms: GRANT USAGE ON *.* TO 'dump'@'%' IDENTIFIED BY ... GRANT SELECT, LOCK TABLES ON `mysql`.* TO 'dump'@'%' GRANT SELECT, LOCK TABLES ON `myschema`.* TO 'dump'@'%' I want to dump all data (included triggers and procedures) using the dump user. I call mysqldump in the following way: mysqldump -u dump -p --routines --triggers --quote-names --opt \ --add-drop-database --databases myschema > myschema.sql Everything is OK with the dumped file

Import MySQL database into a MS SQL Server

ε祈祈猫儿з 提交于 2019-11-26 23:49:39
I have a .sql file from a MySQL dump containing tables, definitions and data to be inserted in these tables. How can I convert this database represented in the dump file to a MS SQL Server database? Use SQL Server Migration Assistant (SSMA) In addition to MySQL it supports Oracle, Sybase and MS Access. It appears to be quite smart and capable of handling even nontrivial transfers. It also got some command line interface (in addition to GUI) so theoretically it can be integrated into some batch load process. This the current download link for MySQL version https://www.microsoft.com/en-us