mysqldump

Mysql导入导出工具Mysqldump和Source命令用法详解

戏子无情 提交于 2019-12-01 04:03:45
mysqldump -u 用户名 -p [--opt] DATABASENAME [Table] >导出SQL文件名 例子: mysqldump -h host -u user -p --opt databasename [table] > /home/user/databasename.sql 使用Mysqldump导出数据表结构 mysqldump -u root -p --no-data mysql user >D:\PHPWeb\sqlbackup\mysql_user.sql Mysql数据库导入命令Source详解   Mysql最常用的数据库导入命令就是Source,Source命令的用法非常简单,首先你需要进入Mysql数据库的命令行管理界面,然后选择需要导入的数据库,即 USER 数据库 source 已导出的SQL文件 来源: oschina 链接: https://my.oschina.net/u/92865/blog/403186

[Linux] RHEL MySQL部署文档

天涯浪子 提交于 2019-12-01 04:02:26
MySQL部署文档: Mysql 数据库使用 基础 1. 安装参数说明: ./configure--prefix=/web/mysql 指定安装目录 --without-debug 去除 debug 模式 --with-extra-charsets=gb2312 添加 gb2312 中文字符支持 --with-charsets= 默认中文字符支持 --enable-assembler 使用一些字符函数的汇编版本 --without-isam 去掉 isam 表类型支持 现在很少用了 isam 表是一种依赖平台的表 --without-innodb 去掉 innodb 表支持 innodb 是一种支持事务处理的表 , 适合企业级应用 --with-pthread 强制使用 pthread 库 (posix 线程库 ) --enable-thread-safe-client 以线程方式编译客户端 --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static 以纯静态方式编译服务端和客户端 --with-tcp-port=3306 端口号 --with-mysqld-user=work 用户 --with-unix-socket-path 将 MYSQL_UNIX_PORT 环境变量设置为 Unix

mysql导入/导出(备份)

泪湿孤枕 提交于 2019-12-01 03:36:08
使用mysql客户端工具进行导入导出,如果使用navicat工具导出,那么导入最好也使用navicat工具,这样就不存在什么问题,导入导出时,最好先看一下sql文件中有没有指定对应哪个数据库,如果没有指定,最好先进入对应的数据库,再运行sql文件。 使用mysqldump命令导入导出,一般导出的数据都包含drop表和create表的语句,如果不需要drop表的语句时,可以在导出的时候就设定,mysqldump使用参考: mysql命令行备份数据库 source命令适用 虽然mysqldump也有导入命令,但是mysql数据库最常用的导入命名却是source,只要是.sql类型的文件,都可以使用source导入,source命令的用法非常简单。首先你进入Mysql数据库的命令行管理界面,然后use需要导入的数据库(如果在sql文件中明确了使用哪个数据库,在外面耶可以不指定),执行导入命令: mysql> source /home/cdh/cm/cm701.sql source导入命令,适用于mysqldump命令、navicat工具、SQLyog工具导出的数据,但是mysql客户端工具导出的数据,有可能在某个注释的地方提示有问题,我们只要把对应的注释语句删掉就可以。 source命令还可以导入大型的.sql类型的文件。如果你导入的文件比较大,使用source命令前,记得去/etc

php exec() - mysqldump creates an empty file

早过忘川 提交于 2019-12-01 03:07:13
I want to create a backup from a database, but I get only a blank file. include('config.php'); $command = "mysqldump --opt -h ".$_host." -u ".$_user." -p ".$_pass." ".$_db." > test.sql"; exec($command); echo "<br />".$command; test.sql is created where the .php file is located. Edit: Note! I'm using XAMPP WINDOWS ! Solution: Because I'm using a Windows Web Server (XAMPP), I needed to specify the path: $command = 'd:\xampp\mysql\bin\mysqldump --opt -u '.$_user.' -p'.$_pass.' '.$_db.' > test.sql'; I removed the space between the -p and the pass. It looks like: -pMYPASSWORD Replaced " with ' I

How to copy a database with mysqldump and mysql in Python?

淺唱寂寞╮ 提交于 2019-12-01 00:31:52
I am writing a simple Python script to copy a MySQL database. I am attempting to copy the database based on the following SO questions and their answers: " Copy/duplicate database without using mysqldump ", " python subprocess and mysqldump " and " Python subprocess, mysqldump and pipes ". However, my script does not work for some reason I cannot see as the tables and the data do not appear in my new database. I can see from my output that the mysqldump works correctly (I see a "Dump completed on..." in my output), so I think that something is wrong with my pipeline . Here is my script: #!/usr

php exec() - mysqldump creates an empty file

对着背影说爱祢 提交于 2019-11-30 23:21:14
问题 I want to create a backup from a database, but I get only a blank file. include('config.php'); $command = "mysqldump --opt -h ".$_host." -u ".$_user." -p ".$_pass." ".$_db." > test.sql"; exec($command); echo "<br />".$command; test.sql is created where the .php file is located. Edit: Note! I'm using XAMPP WINDOWS ! Solution: Because I'm using a Windows Web Server (XAMPP), I needed to specify the path: $command = 'd:\xampp\mysql\bin\mysqldump --opt -u '.$_user.' -p'.$_pass.' '.$_db.' > test

MySQL备份与恢复(5)mysqldump的关键参数说明

给你一囗甜甜゛ 提交于 2019-11-30 23:12:07
关键参数:mysqldump --help 1、-B  指定多个库,增加建库语句和use语句。 2、--compact  去掉注释,适合调试输出,生产不用。 3、-A  备份所有库。 4、-F  刷新binlog日志 5、--master-data  增加binlog日志文件及对应的位置点。 6、-x,--lock-all-tables 7、-l,--lock-tables 8、-d   只备份表结构 9、-t  只备份数据 10、--single-transaction  适合innodb事务数据库备份     InnoDB表在备份时,通常启用选项 --single-transaction 来保证备份的一致性,实际上它的工作原理是设定本次会话的隔离级别为:REPEATABLE READ,以确保本次会话(dump)时,不会看到其他会话已经提交了的数据。          myisam备份命令:     mysqldump -uroot -pdubin -A -B -F --master-data=2 -x --events|gzip >/opt/all.sql.gz     innodb备份命令:(推荐使用的)     mysqldump -uroot -pdubin -A -B -F --master-data=2 --events --single-transaction

MySQL备份与恢复(4)mysqldump备份表

扶醉桌前 提交于 2019-11-30 23:09:08
一、备份单个表     语法:mysqldump -u 用户名 -p 数据库名 表名 >备份的文件名     mysqldump -u root -pdubin oldboy test >/opt/table.sql     执行结果: [root@localhost ~]# mysqldump -u root -pdubin oldboy test >/opt/table.sql [root@localhost ~]# egrep -v "#|\*|--|^$" /opt/table.sql DROP TABLE IF EXISTS `test`; CREATE TABLE `test` ( `id` int(4) NOT NULL AUTO_INCREMENT, `name` char(20) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; LOCK TABLES `test` WRITE; INSERT INTO `test` VALUES (1,'oldboy'),(2,'oldgirl'),(3,'inca'),(4,'zuma'),(5,'kaka'); UNLOCK TABLES; 二、备份多个表     语法:mysqldump -u 用户名

Automate MySQLdump to local computer (Windows)

杀马特。学长 韩版系。学妹 提交于 2019-11-30 22:47:32
I'd like to automate a mysqldump to my computer from a remote host, and I cannot figure out how to do it. I suppose that I should run a mysqldump through an SSH tunnel, but this becomes complicated by the fact that my local computer is a Windows XP machine. I'm using putty to open a tunnel like so: putty -load "[my saved session]" -L [localport]:localhost:3306 -N Note: I can't just connect to the mysql server remotely. Instead of PuTTY, download the command line version plink.exe . Then using the same connection parameters you can run the mysqldump via plink and save the output locally. PLink

MySQL备份与恢复(2)mysqldump多个命令参数

删除回忆录丶 提交于 2019-11-30 22:26:24
一、备份单个数据库练习多种参数使用     mysql数据库自带了一个很好用的备份命令,就是mysqldump,它的基本使用如下:     语法:mysqldump -u 用户名 -p 数据库名 >备份的文件名 mysql> select * from test; +----+---------+ | id | name | +----+---------+ | 1 | oldboy | | 2 | oldgirl | | 3 | inca | | 4 | zuma | | 5 | kaka | +----+---------+ 5 rows in set (0.00 sec) [root@localhost ~]# mysqldump -uroot -pdubin oldboy >/opt/mysql_bak.sql [root@localhost ~]# egrep -v "#|\*|--|^$" /opt/mysql_bak.sql DROP TABLE IF EXISTS `SC`; CREATE TABLE `SC` ( `SCid` int(12) NOT NULL AUTO_INCREMENT COMMENT '主键', `Cno` int(10) NOT NULL COMMENT '课程号', `Sno` int(10) NOT NULL COMMENT '学号',