mysqldump

Exporting database through my java code

不打扰是莪最后的温柔 提交于 2019-12-05 14:55:41
I want to export my MySQL database using my java code. But I have not found any way to do. What I want to do that there is a button in my app as "Export Database". When that button is clicked, my database should be exported to specified path. I have used the following code but it does'nt worked : Runtime runtime = Runtime.getRuntime(); runtime.exec("C:\\Program Files\\MySql\\MySql Server 5.5\\bin\\mysqldump -u root -p myDatabase> D:\\backup.sql"); How should I do this task. Thanks. Two problems : the space between -p and the password the space inside the path to the executable Prefer this :

MySQL data export changes times

混江龙づ霸主 提交于 2019-12-05 13:12:08
问题 I have some backup and restore scripts that I am using for my database. The table has a timestamp field. The backup script looks like this: mysqldump -u user -ppass database --tab="../" --fields-terminated-by="|" --skip-comments table It creates two files, table.sql and table.txt. The restore script looks like this: mysql -u user -ppass database < "../table.sql" mysqlimport -u user -ppass --local --fields-terminated-by="|" database "../table.txt" However the backup script is outputting the

MySQL性能调优与架构设计--mysql自带工具使用

落爺英雄遲暮 提交于 2019-12-05 12:23:37
1、mysql: 个人的提示符定义: "\\u@\\h : \\d \\r:\\m:\\s> ",显示效果: “sky @localhost : test 04:25:45>” 2、mysqladmin Usage: mysqladmin [OPTIONS] command command ... mysqadmin,顾名思义,提供的功能都是与MySQL 管理相关的各种功能。如MySQL Server 状态检查,各种统计信息的flush,创建/删除数据库,关闭MySQL Server 等等。mysqladmin 所能做的事情,虽然大部分都可以通过mysql 连接登录上MySQL Server 之后来完成,但是 大部分通过mysqladmin 来完成操作会更简单更方便。这里我将介绍一下自己经常使用到的 几个常用功能: ping 命令可以很容易检测MySQL Server 是否还能正常提供服务 sky @sky :~# mysqladmin -u sky -ppwd -h localhost ping mysqld is alive status 命令可以获取当前MySQL Server 的几个基本的状态值: sky @sky :~# mysqladmin -u sky -ppwd -h localhost status Uptime: 20960 Threads: 1

How to import SQL dump to a table without overwriting duplicate fields

时光毁灭记忆、已成空白 提交于 2019-12-05 10:17:52
how do I import a MySQL dump file to a database without overwriting records with the same value? Shoban Here is the link to the manual. You can specify whether to replace existing records. --replace, -r The --replace and --ignore options control handling of input rows that duplicate existing rows on unique key values. If you specify --replace , new rows replace existing rows that have the same unique key value. If you specify --ignore , input rows that duplicate an existing row on a unique key value are skipped. If you do not specify either option, an error occurs when a duplicate key value is

mysql5.7上使用mysqldump

浪尽此生 提交于 2019-12-05 10:00:27
# mysqldump -utmp -ptmp -h127.0.0.1 -P3307 --single-transaction --master-data=2 --all-databases > 3307_20191123.sql mysqldump: [Warning] Using a password on the command line interface can be insecure. Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --events.# mysqldump -utmp -ptmp -h127.0.0.1 -P3307 --single-transaction --master-data=2 --all

shell脚本备份mysql数据库

笑着哭i 提交于 2019-12-05 09:52:06
https://github.com/aminglinux/shell20 一台MySQL服务器,跑着5个数据库,在没有做主从的情况下,需要对这5个库进行备份,具体要求如下: 1)每天备份一次,需要备份所有的库 2)把备份数据存放到/data/backup/下 3)备份文件名称格式示例:database_name-2018-11-11.sql 4)需要对1天以前的所有sql文件压缩,格式为gzip 5)本地数据保留1周 6)需要把备份的数据同步到远程备份中心,假如本机可以直接通过rsync命令同步,同步目标地址为rsync://10.10.20.100/mysqlbak/ 7)远程备份数据要求保留1个月 拿到需求后,我们不应该马上就动手,而是应该先分析需求点,准备好储备知识。如果你没有足够的储备知识,无论脚本语法掌握的多么熟练,这个脚本也是不能完成的。本脚本的核心知识点是如何备份所有的库。 知识点一:MySQL数据库备份 假设已知备份数据的用户为backup,密码为34KpmyzUq,要备份的5个数据库分别为db1-db5。 备份数据库的命令为: mysqldump -ubackup -p34KpmyzUq db1 > db1.sql 如果是远程的MySQL服务,还可以加上IP和Port,例如: mysqldump -ubackup -p34KpmyzUq -h192.168

error 1064(42000) while trying to execute mysqldump command [duplicate]

你说的曾经没有我的故事 提交于 2019-12-05 09:14:49
问题 This question already has answers here : Error while taking backup with mysqldump in mysql command line (5 answers) Closed 4 years ago . im trying to run the following command: mysql> mysqldump --all-databases > dump.sql; on my local(On my pc) Mysql 5.5 server but I keep getting this error: mysql> mysqldump --all-databases > dump.sql; ERROR 1064 (42000): 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 'mysql

why is the `tcgetattr` error seen when ssh is used for dumping the backup file on another server?

做~自己de王妃 提交于 2019-12-05 08:35:45
I want to dump a tables backup on another server and I am using ssh for doing it. when I run the below command, it gives an error but dump file is copied to destination. mysqldump -u username -ppassword dbname tablename | ssh -t -t servers_username@domain_name 'cat > /tmp/bckp.sql'; tcgetattr: Invalid argument If I press CTRL + c then it appends error message with Killed by signal 2. Why is this error? I've seen this error when forcing pseudo-terminal allocation using ssh -t -t or ssh -tt . The tcgetattr function is used to look up the attributes of the pseudoterminal represented by a file

Can't get mysqldump to connect to local mysql instance (error 2003 / 10061)

空扰寡人 提交于 2019-12-05 08:31:12
I've got mysql 5.1 on a windows xp machine. It's listening on port 3308. I'm trying to use mysqldump: > mysqldump -u root -pmypassword dbname > out.sql Getting an error: mysqldump: Got error: 2003: Can't connect to MySQL server on 'localhost' (10061) when trying to connect Not sure what the problem is, looking at --help dumps variables and shows port=3308 as I set in the mysql installation (instead of default 3306). I don't think there's anything different with my installation. I also tried explicitly setting the port # on the command line but still same error. Thanks To connect through a port

How to restore the database double encoded by mysqldump

前提是你 提交于 2019-12-05 07:01:59
问题 I use the mysqldump to make a backup of my database. My database was destroyed by an accident and now I want to restore it. But the SQL file is double encoded by bug#28969. http://bugs.mysql.com/bug.php?id=28969 Is there any solution for my data to go back? I only have the SQL file made by mysqldump. Thanks. I got my data back. Thanks everyone. By this way, 1.import the messy data 2.use sqldump as 'mysqldump -h "$DB_HOST -u "$DB_USER" -p"$DB_PASSWORD" --opt --quote-names --skip-set-charset -