mysqldump

Split string into row

感情迁移 提交于 2019-12-04 17:18:20
I am using MySQL. I have a table named " class ", the " class " table has three columns name , year and class_code like following: Class table: Now I would like to use the above table to create a new table named " temp ", which contains class_code and value columns. The rule is that each string value in each column field of a row of the above " class " table will be split into words, and each word will be inserted to the " temp " table as value column of a temp table record like following: temp table: I am using MySQL. Is it possible to generate the " temp " table purely by using SQL statement

mysqldump with WHERE id IN (SELECT …) yields table “was not locked” error

喜你入骨 提交于 2019-12-04 16:52:27
问题 I have 2 databases, with ~100,000 rows missing from the table field_collection_item from db1 , which I'd like to repair by exporting from db2 . My plan to accomplish this was to: identify the missing items by item_id in db2 , exporting the list of item_id s. import the item_id s into db1 into a new table missing_field_collection_item Using the following mysqldump to pull the data: mysqldump -u USER -pPASS DATABASE --no-create-info --tables field_collection_item --where="item_id IN (SELECT

Ignore 'views' in mysql db backup using mysqldump

喜欢而已 提交于 2019-12-04 16:31:26
问题 I need to ignore all view in my database and take backup using mysqldump. Currently i am using below option. --ignore-table=view1 --ignore-table=view2 --ignore-table=view3 Is there any way to take backup omitting all views without specifying all 'view' names.? 回答1: If the MySQL user you're using doesn't have access to read Views, then just putting an -f flag on the mysqldump command will skip them. Unfortunately, it prints a warning which might be annoying, but it will otherwise complete the

how to backup and restore mysql database using java

喜你入骨 提交于 2019-12-04 15:44:57
I have a small application which I am going to use to backup and restore a mysql database, coding for backup is as follows and it works properly, .... String command = "mysqldump --host=" + dataBase.getHost() + " --user=" + dataBase.getUserName() + " --password=" + dataBase.getPassword() + " " + dataBase.getDatabaseName() + " -r " + dataBase.getBackupPath() + "/ofm_mnu_backup_" + bkDate + ".sql"; System.out.println(command); Process p = null; try { Runtime runtime = Runtime.getRuntime(); p = runtime.exec(command); int processComplete = p.waitFor(); if (processComplete == 0) { System.out

第九章 备份和恢复

落花浮王杯 提交于 2019-12-04 15:43:32
一.备份的原因 运维工作的核心简单概括就两件事: 1)第一个是保护公司的数据. 2)第二个是让网站能7*24小时提供服务(用户体验)。  备份的原因 1)备份就是为了恢复。 2)尽量减少数据的丢失(公司的损失) 回到顶部(go to top) 二.备份的类型 1.冷备份: 这些备份在用户不能访问数据时进行,因此无法读取或修改数据。这些脱机备份会阻止执行任何使用数据的活动。这些类型的备份不会干扰正常运行的系统的性能。但是,对于某些应用程序,会无法接受必须在一段较长的时间里锁定或完全阻止用户访问数据。 2.温备份: 这些备份在读取数据时进行,但在多数情况下,在进行备份时不能修改数据本身。这种中途备份类型的优点是不必完全锁定最终用户。但是,其不足之处在于无法在进行备份时修改数据集,这可能使这种类型的备份不适用于某些应用程序。在备份过程中无法修改数据可能产生性能问题。 3.热备份: 这些动态备份在读取或修改数据的过程中进行,很少中断或者不中断传输或处理数据的功能。使用热备份时,系统仍可供读取和修改数据的操作访问。 回到顶部(go to top) 三.备份的方式 1.逻辑备份: 基于SQL语句的备份 1)binlog 2)into outfile mysql> select * from world.city into outfile '/tmp/world_city.data'; 3

mysql 备份数据

杀马特。学长 韩版系。学妹 提交于 2019-12-04 15:33:19
1、备份命令 格式:mysqldump -h主机名 -P端口 -u用户名 -p密码 --database 数据库名 > 文件名.sql 例如: mysqldump -h 192.168.1.100 -p 3306 -uroot -ppassword --database cmdb > /data/backup/cmdb.sql 2、备份压缩 导出的数据有可能比较大,不好备份到远程,这时候就需要进行压缩 格式:mysqldump -h主机名 -P端口 -u用户名 -p密码 --database 数据库名 | gzip > 文件名.sql.gz 例如: mysqldump -h192.168.1.100 -p 3306 -uroot -ppassword --database cmdb | gzip > /data/backup/cmdb.sql.gz 3、备份同个库多个表 格式:mysqldump -h主机名 -P端口 -u用户名 -p密码 --database 数据库名 表1 表2 .... > 文件名.sql 例如 mysqldump -h192.168.1.100 -p3306 -uroot -ppassword cmdb t1 t2 > /data/backup/cmdb_t1_t2.sql 4、同时备份多个库 格式:mysqldump -h主机名 -P端口 -u用户名

Python subprocess, mysqldump and pipes

烂漫一生 提交于 2019-12-04 13:59:52
I've got a problem trying to build a easy backup/upgrade database script. The error is in the mysqldump call using subprocess: cmdL = ["mysqldump", "--user=" + db_user, "--password=" + db_pass, domaindb + "|", "gzip", ">", databases_path + "/" + domaindb + ".sql.gz"] print "%s: backup database %s \n\t[%s]" % (domain, domaindb, ' '.join(cmdL)) total_log.write("%s: backup database %s \n\t[%s] \n" % (domain, domaindb, ' '.join(cmdL))) p = subprocess.Popen(cmdL, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) Before that cose, i redirect sys.stdout and sys.stderr to files, in order to have a log

mysql备份

一世执手 提交于 2019-12-04 13:41:31
冷备份 cp scp 冷恢复 cp scp #1修改auto.cnf #如果是root权限,修改/var/lib/mysql下所有文件属主 属组成Mysql 热备份 mysqldump 库名 > 文件 #提取备份库 mysqldump 库名 表名 > 文件 #提取备份表 mysqldump --all-databases > 文件 #提取备份所有库 热恢复 mysql < 文件 mysql >source /路径/文件 锁表 flush tables with read lock; 解锁 unlock tables; show slave status\G stop slave; SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; #写多少跳过多少条错误 start slave; show slave status\G stop slave; SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 0; start slave; show slave status\G 来源: https://www.cnblogs.com/renyz/p/11868608.html

mysql备份

泄露秘密 提交于 2019-12-04 13:29:25
一.备份的原因 运维工作的核心简单概括就两件事: 1)第一个是保护公司的数据. 2)第二个是让网站能7*24小时提供服务(用户体验)。 1)备份就是为了恢复。 2)尽量减少数据的丢失(公司的损失) 二.备份的类型 冷备份: 这些备份在用户不能访问数据时进行,因此无法读取或修改数据。这些脱机备份会阻止执行任何使用数据的活动。这些类型的备份不会干扰正常运行的系统的性能。但是,对于某些应用程序,会无法接受必须在一段较长的时间里锁定或完全阻止用户访问数据。 停库,停服务,备份 温备份: (锁表) 这些备份在读取数据时进行,但在多数情况下,在进行备份时不能修改数据本身。这种中途备份类型的优点是不必完全锁定最终用户。但是,其不足之处在于无法在进行备份时修改数据集,这可能使这种类型的备份不适用于某些应用程序。在备份过程中无法修改数据可能产生性能问题。 热备份: 这些动态备份在读取或修改数据的过程中进行,很少中断或者不中断传输或处理数据的功能。使用热备份时,系统仍可供读取和修改数据的操作访问。 三.备份的方式 逻辑备份: 基于SQL语句的备份 1)binlog 2)into outfile mysql> select * from world.city into outfile '/tmp/world_city.data'; #配置文件中创建/tmp 3)mysqldump只支持全备 4

ERROR 1465 “Triggers can not be created on system tables” after restore from SQL created by mysqldump

你离开我真会死。 提交于 2019-12-04 11:15:29
I'm running a mysql 5.6 server on amazon RDS and set up a read replica I use to create backups using mysqldump. I tried with the "--all-databases" option, but when I'm trying to import the SQL created by mysqldump, I end up with this error from the mysql command client: ERROR 1465 "Triggers can not be created on system tables" I used "--all-databases" because I basically want to restore everything in RDS as it was before in case of a crash. Maybe that's wrong, and I should only select my schemas (plus the mysql.users table)? But what is "--all-databases" for in the first place, if it would