mysqldump

How to use MySQL dump from a remote machine

点点圈 提交于 2019-11-28 15:30: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. Try it with Mysqldump #mysqldump --host=the.remotedatabase.com -u yourusername -p yourdatabasename > /User/backups/adump.sql 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 output of the previous command and store it in this file." Note: The lack of a space between -p and the mysql

MySQLDump one INSERT statement for each data row

淺唱寂寞╮ 提交于 2019-11-28 15:15:26
with the following statement: mysqldump --complete-insert --lock-all-tables --no-create-db --no-create-info --extended-insert --password=XXX -u XXX --dump-date yyy > yyy_dataOnly.sql I get INSERT statements like the following: INSERT INTO `table` VALUES (1,'something'),(2,'anything'),(3,'everything'); What I need in my case is something like this: INSERT INTO `table` VALUES (1,'something'); INSERT INTO `table` VALUES (2,'anything'); INSERT INTO `table` VALUES (3,'everything'); Is there a way to tell "mysqldump" to create a new INSERT statement for each row? Thanks for your help! driis Use:

Limiting the number of records from mysqldump?

天涯浪子 提交于 2019-11-28 15:10:30
I am trying to load a small sample of records from a large database into a test database. How do you tell mysqldump to only give you n records out of 8 million? Thanks As skaffman says, use the --where option: mysqldump --opt --where="1 limit 1000000" database Of course, that would give you the first million rows from every table. If you want to get n records from a specific table you can do something like this: mysqldump --opt --where="1 limit 1000000" database table > dump.sql This will dump the first 1000000 rows from the table named table into the file dump.sql . mysqldump can be given a

mysql分库分表备份脚本

醉酒当歌 提交于 2019-11-28 14:52:06
#!/bin/sh ####################################################### #ShellName:mysql database and tables backup #Author:zkg #Created Time:2019-08-26 #Blog Address: https://blog.51cto.com/1009516 ####################################################### #调用系统函数库 . /etc/init.d/functions #Define variables BACKUPDIR=/data/mysqlbak/ MYSQLUSER=root MYSQLPASSWD=DbApp MYSQLSOCK=/data/mysql/tmp/mysql.sock MYSQLCMD="/data/mysql/bin/mysql -u$MYSQLUSER -p$MYSQLPASSWD -S $MYSQLSOCK" MYSQLDUMP="/data/mysql/bin/mysqldump -u$MYSQLUSER -p$MYSQLPASSWD -S $MYSQLSOCK -x -F -R" DATABASELIST=" $MYSQLCMD -e "show

mysqldump备份还原和mysqldump导入导出语句大全详解

北城以北 提交于 2019-11-28 14:51:47
mysqldump备份还原和mysqldump导入导出语句大全详解 mysqldump备份 : mysqldump -u用户名 -p密码 -h主机 数据库 a -w "sql条件" --lock-all-tables > 路径 案例: mysqldump -uroot -p1234 -hlocalhost db1 a -w "id in (select id from b)" --lock-all-tables > c:\aa.txt mysqldump还原 : mysqldump -u用户名 -p密码 -h主机 数据库 < 路径 案例: mysql -uroot -p1234 db1 < c:\aa.txt mysqldump按条件导出 : mysqldump -u用户名 -p密码 -h主机 数据库 a --where "条件语句" --no-建表> 路径 mysqldump -uroot -p1234 dbname a --where "tag='88'" --no-create-info> c:\a.sql mysqldump按导入 : mysqldump -u用户名 -p密码 -h主机 数据库 < 路径 案例: mysql -uroot -p1234 db1 < c:\a.txt mysqldump导出表 : mysqldump -u用户名 -p密码 -h主机 数据库 表

mysql备份指定条件的sql脚本

依然范特西╮ 提交于 2019-11-28 14:51:32
mysqldump -uroot -proot DBName tabaleName -w" 条件='????' " --lock-all-tables > 目标路径 导入 进入mysql.exe mysql>source d:tmp\1.sql 转自:http://blog.chinaunix.net/uid-27038861-id-3591736.html mysqldump备份还原和mysqldump导入导出语句大全详解 mysqldump备份 : mysqldump -u用户名 -p密码 -h主机 数据库 a -w "sql条件" --lock-all-tables > 路径 mysqldump还原 : mysqldump -u用户名 -p密码 -h主机 数据库 < 路径 mysqldump按条件导出 : mysqldump -u用户名 -p密码 -h主机 数据库 a --where "条件语句" --no-建表> 路径 mysqldump -uroot -p1234 dbname a --where "tag='88'" --no-create-info> c:\a.sql mysqldump按条件导入 : mysqldump -u用户名 -p密码 -h主机 数据库 < 路径 案例: mysql -uroot -p1234 db1 < c:\a.txt

Using PHP script: why mysqldump does not dump sql file?

£可爱£侵袭症+ 提交于 2019-11-28 14:24:56
Hye, I'm new in PHP and trying to use mysqldump using php script. I already try using command and the dump process is success. The situation is, when I tried dump using my local computer, the dump is succeed. But when the code is transfer into the server, mysqldump doesn't work. I have tried almost the solution related to mysqldump topics, but still it doesn't work. I hope someone can guide me. TQ <?php /*----------------------------------------------- MYSQLDUMP FOR SERVER ------------------------------------------*/ $dbhost = "*****"; $dbuser = "*****"; $dbpass = "*****"; $dbname = "*****"; /

Import MySQL dump into R (without requiring MySQL server)

ぐ巨炮叔叔 提交于 2019-11-28 14:07:01
Packages like RMySQL and sqldf allow one to interface with local or remote database servers. I'm creating a portable project which involves importing sql data in cases (or on devices) which do not always have access to a running server, but which do always have access to the latest .sql dump of the database. The goal seems simple enough: import an .sql dump into R without the involvement of a MySQL server. More specifically, I'd like to create a list of lists in which the elements correspond to any databases defined in the .sql dump (there may be multiple), and those elements in turn consist

MYSQL常用的命令

老子叫甜甜 提交于 2019-11-28 13:58:29
启动:net start mySql;   进入:mysql -u root -p/mysql -h localhost -u root -p databaseName;   列出数据库:show databases;   选择数据库:use databaseName;   列出表格:show tables;   显示表格列的属性:show columns from tableName;   建立数据库:source fileName.txt;   匹配字符:可以用通配符_代表任何一个字符,%代表任何字符串;   增加一个字段:alter table tabelName add column fieldName dateType;   增加多个字段:alter table tabelName add column fieldName1 dateType,add columns fieldName2 dateType;   多行命令输入:注意不能将单词断开;当插入或更改数据时,不能将字段的字符串展开到多行里,否则硬回车将被储存到数据中;   增加一个管理员帐户:grant all on *.* to user@localhost identified by "password";   每条语句输入完毕后要在末尾填加分号';',或者填加'\g'也可以;   查询时间:select

Mysql常用基本命令

末鹿安然 提交于 2019-11-28 13:57:31
mysql的默认安装目录 linux:/var/lib/mysql/ windows: C:\Program Files\MySQL\ mysql命令行历史记录文件 ~/.mysql_history 在Linux下启动Mysql。 #/etc/init.d/mysql stop #/etc/init.d/mysql start 重启mysql服务 #/etc/init.d/mysql restart 查看mysql运行状态 # / etc / init.d / mysql status 登录到mysql #mysql -u root -h localhost -p Enter password: -h是host的缩写,表示登录到哪一个mysql服务器,localhost是本地。 如果要登录到222.222.222.222的mysql服务器可以这样写: #mysql -u root -h 222.222.222.222 -p Enter password: 显示mysql中所有的数据库 >show databases; 显示test数据库中所有的表 >use test; >show tables; 用来设置客户端的字符集的,与服务器端的字符集无关 如果你用终端登录进mysql来查询包含中文的数据时,如果没法查到数据或中文为乱码,可以尝试设置这个来解决问题 set names gbk;