mysqldump

Slow performance using mysqldump from C#

笑着哭i 提交于 2019-12-11 01:04:03
问题 I'm trying to launch mysqldump from my C# console application using this code: ProcessStartInfo procInfo = new ProcessStartInfo("mysqldump", "avisdb -uroot -p" + cs.Password); procInfo.CreateNoWindow = true; procInfo.RedirectStandardOutput = true; procInfo.UseShellExecute = false; Process proc = new Process(); proc.StartInfo = procInfo; proc.Exited += new EventHandler(proc_Exited); proc.Start(); proc.WaitForExit(); File.Delete("dump.sql"); StreamWriter dump = File.AppendText("dump.sql"); dump

Execute interdependent views from mysqldump backup

假如想象 提交于 2019-12-10 21:56:03
问题 mysqldump creates a dump with the tables (and views) listed alphabetically. When there are foreign key relationships between the tables this is not very convenient, however, the problem is easily resolved by running: SET FOREIGN_KEY_CHECKS=0; I have a situation whereby the view, vwapple, is dependent on the view, vworange, say. With the mysqldump, vwapple is listed and executed before vworange, which is problematic as we'll get a "view vworange does not exist" error message. How is this

using subprocess.call with mysqldump

╄→гoц情女王★ 提交于 2019-12-10 16:25:15
问题 I have been scripting with windows for many years and have only started to look at python as an alternative in the last few weeks. I'm trying to write a native python script to backup a mysql database with mysqldump. I normally do this with a command line piping the output > without issue. I see many answers with subprocess.popen and shell=True, equally I see many statements say I should avoid shell=True So I'm trying to get the following code to redirect my stdout to a file, all without

truncate table via command line in Linux

喜你入骨 提交于 2019-12-10 12:53:41
问题 I want to truncate one of my db table using mysqldump command so that I can place that command in sh file for executing it on daily basis. Do any one know about this command? Thanks in advance 回答1: You can use mysql command line client to do it mysql -h dbserver_hostname -e "truncate table schema_name.table_name" 回答2: localhost=hostname root=username ''=password demo=db name language=table name #to truncate a table from database mysql -h localhost -u root -p'' demo -e "truncate table demo

flush tables - access denied

一世执手 提交于 2019-12-10 12:36:37
问题 I need to back my database, but when trying to flush the tables before backing up I get this error? What does it mean by RELOAD privilege? Can't find any RELOAD privilege in phpmyadmin!? Error: Access denied; you need the RELOAD privilege for this operation SQL: FLUSH TABLES WITH READ LOCK 回答1: Probably you're not running FLUSH command using root, but with a limited user. You need to be granted RELOAD privilege to run FLUSH command. Take a look here for MySQL privileges. So (for example) root

mysqldump 参数详解

一个人想着一个人 提交于 2019-12-10 07:47:37
-A, --all-databases :导出全部数据库 -Y, --all-tablespaces :导出全部表空间 -y, --no-tablespaces : 不导出任何表空间信息 --add-drop-database :每个数据库创建之前添加drop数据库语句 --add-drop-table :每个数据表创建之前添加drop数据表语句(默认打开,使用 --skip-add-drop-table 取消选项) --add-drop-trigger : --add-locks : 表导出前增加 LOCK TABLES 并且之后 UNLOCK TABLE(默认打开,使用 --skip-add-locks 取消选项) --allow-keywords :允许创建是关键词的列名字 --apply-slave-statements :在’CHANGE MASTER’前添加’STOP SLAVE’,并且在导出的最后添加’START SLAVE’ --bind-address : --character-sets-dir :字符集文件的目录 --column-statistics : -i, --comments : 附加注释信息(默认打开,可以用 --skip-comments 取消) --compatible :导出更少的输出信息,用于调试(去掉注释和头尾等结构)可以使用选项:

linux上mysql库的迁移

柔情痞子 提交于 2019-12-10 04:58:10
两种办法 第一种: 首先将/var/lib/mysql这个目录备份起来, 在恢复的时候直接将mysql目录下的数据库拷贝到另外一个系统的数据库中即可,另外还需拷贝/mysql/下的ibdata1这个文件到另外一个系统数据库/var/lib/mysql目录下,如该目录下有,就覆盖。 后重新启动mysql数据库,若打开页面出现系统错误,请重新启动服务器(reboot) 此种方法有局限容易出错,不推荐使用 第二种 原理: 备份+还原 1. 在原机器上: mysqldump -u root -p 数据库名称 > 备份文件名称 提示输入密码,开始备份。 出现mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect的问题,解决方法是, #mysql -u root -p >update mysql.user set password=password('123') where user='root'; >quit 出现mysqldump: Got error: 1045: Access denied for user 'smb_behavior'@'localhost' (using password: YES) when

mysqldump备份大数据出错

我们两清 提交于 2019-12-10 04:37:55
mysqldump备份大数据出错 技术 maybe yes 发表于 2015-01-26 22:58 原文链接 : http://blog.lmlphp.com/archives/72 来自 : LMLPHP后院 网 站的数据会定期备份,现在数据大了,mysqldump 方法估计是不行了,并且失败了以后并不能接着上次的位置开始备份。报错内容:mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table `table name` at row: 23699。 Lost connection to MySQL server,在使用 mysqldump 的时候(尤其是向 NFS 上备份的时候),很多人都被“mysqldump:Got error:2013: Lost connection to MySQL server during query when dumping table”的问题困扰,在Manual中对这个问题有一些简单的说明。 在向NFS上备份的时候,数据的流向是这样的:MySQL Server 端从数据文件中检索出数据,然后分批将数据返回给mysqldump 客户端,然后 mysqldump 将数据写入到NFS上。一般地,向 NFS

Piping mysqldump to mysql

混江龙づ霸主 提交于 2019-12-10 02:43:07
问题 Sometimes I need to copy MySQL database (db1) to another database (db2). I found this command to be concise and effective: mysqldump --opt db1 | mysql db2 It was working fine, but now it breaks with following error: ERROR 1064 (42000) at line 1586: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysqldump: Couldn't execute 'SHOW TRIGGERS LIKE 'some_table_name'': MySQL server ' at line 1 First thing that

MySQL主从(Master-Slave)复制

心已入冬 提交于 2019-12-09 11:27:46
本文内容主要来源:官方文档中文版第6章“ MySQL中的复制 ”。本文只记录配置要点。 1. 主数据库配置(通常在 /etc/my.cnf ): 在 [mysqld] 中加入以下几条配置: server-id=1(为任意值) log-bin=mysql-bin binlog_do_db=你要复制的数据库(实际上是要做 二进制日志 的数据库) binlog_ignore_db=mysql(要忽略的数据库) 重启MySQL服务器后进入client,创建数据库用户以便“从数据库”连接: GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%.mydomain.com' IDENTIFIED BY 'slavepass'; (用户名、密码以及从服务器主机地址可自定义) 然后刷新读写缓冲区并锁定表读写操作: FLUSH TABLES WITH READ LOCK; 这个时候再另外连接到主机shell(不要关闭当前MySQL连接,否则锁定会解除),开始复制数据库到从数据库(事先要创建同名数据库,也可以使用“ mysqladmin -h 从服务器地址 create 数据库名 ”进行创建): mysqldump --opt 要复制的数据库 -p主数据库root密码 -R -B | mysql -h从服务器地址 要复制的数据库名 -p从数据库root密码 复制完后