mysqldump

mysqldump problems with restore error: 'Please DISCARD the tablespace before IMPORT'

爷,独闯天下 提交于 2019-12-29 03:53:09
问题 I run a daily backup mysqldump backup of the production database (mysql version 5.1.66): mysqldump --user=username --password=secret -C -e --create-options --hex-blob --net_buffer_length=5000 databasename > file I also do a daily restore of that database on my development machine (mysql version 5.6.12) mysql --user=username --password=secret databasename < file I get the error: ERROR 1813 (HY000) at line 25: Tablespace for table ' databasename . tablename ' exists. Please DISCARD the

How to use mysqldump for a portion of a table?

三世轮回 提交于 2019-12-29 02:33:28
问题 So I can export only a table like this: mysqldump -u root -p db_name table_name > table_name.sql Is there any way to export only a portion of a table with mysqldump? For example, 0 - 1,000,000 rows, 1,000,000 - 2,000,000 rows, etc. Should I do this with mysqldump or a query? 回答1: mysqldump -uroot -p db_name table_name --where='id<1000000' or you can use SELECT * INTO OUTFILE 'data_path.sql' from table where id<100000 回答2: mysqldump --skip-triggers --compact --no-create-info --user=USER -

Limiting the number of records from mysqldump?

て烟熏妆下的殇ゞ 提交于 2019-12-29 02:18:07
问题 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 回答1: 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. 回答2: 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

mysqldump with multiple tables with or without where clause

喜夏-厌秋 提交于 2019-12-28 13:38:34
问题 I have a set of tables in my database that I have to take a dump ( :D ) of. My problem is I want to take some data from some tables that only date back certain days and would like to keep the remaining tables in tact. The query I came up with was something like: mysqldump -h<hostname> -u<username> -p <databasename> <table1> <table2> <table3> <table4> --where 'created > DATE_SUB(now(), INTERVAL 7 DAY)', <table5> --where 'created > DATE_SUB(now(), INTERVAL 7 DAY) --single-transaction --no

mysql导入导出sql文件

六月ゝ 毕业季﹏ 提交于 2019-12-28 11:37:09
首先linux 下查看mysql相关目录 root@ubuntu14:~# whereis mysql mysql: /usr/bin/mysql---- mysql的运行路径 /etc/mysql /usr/lib/mysql----- mysql的安装路径 /usr/bin/X11/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz 此外还有一个: var/lib/mysql --------mysql数据库data文件的存放路径 确定了运行路径,执行导入、导出mysql数据库命令 一、导出数据库用mysqldump命令 (注意:先cd到mysql的运行路径下,再执行一下命令): 1、导出数据和表结构: mysqldump -u用户名 -p密码 数据库名 > 数据库名.sql mysqldump -uroot -p dbname > dbname .sql 敲回车后会提示输入密码 2、只导出表结构 mysqldump -u用户名 -p密码 -d 数据库名 > 数据库名.sql mysqldump -uroot -p -d dbname > dbname .sql 二、导入数据库 1、首先建空数据库 mysql>create database dbname ; 2、导入数据库 方法一: (1)选择数据库 mysql>use

centos mysql 操作

爷,独闯天下 提交于 2019-12-26 23:09:07
安装mysql yum -y install mysql-server 修改mysql配置 vi /etc/my.cnf 这里会有很多需要注意的配置项,后面会有专门的笔记 暂时修改一下编码(添加在密码下方): default-character-set = utf8 设置mysql随系统启动 # chkconfig mysqld on  ← 设置MySQL服务随系统启动自启动 # chkconfig --list mysqld  ← 确认MySQL自启动mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off  ← 如果2--5为on的状态就OK # /etc/rc.d/init.d/mysqld start  ← 启动MySQL服务 显示当前mysql版本和当前日期 select version(),current_date; 修改mysql root密码 # mysql -u root  ← 用root用户登录MySQL服务器 select user,host,password from mysql.user;  ← 查看用户信息 set password for root@localhost=password('在这里填入root密码');  ← 设置root密码 select user,host,password from mysql

CentOS中Mysql常用操作

杀马特。学长 韩版系。学妹 提交于 2019-12-26 23:07:04
安装mysql yum -y install mysql-server 修改mysql配置 vi /etc/my.cnf 这里会有很多需要注意的配置项,后面会有专门的笔记 暂时修改一下编码(添加在密码下方): default-character-set = utf8 设置mysql随系统启动 # chkconfig mysqld on  ← 设置MySQL服务随系统启动自启动 # chkconfig --list mysqld  ← 确认MySQL自启动mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off  ← 如果2--5为on的状态就OK # /etc/rc.d/init.d/mysqld start  ← 启动MySQL服务 显示当前mysql版本和当前日期 select version(),current_date; 修改mysql root密码 # mysql -u root  ← 用root用户登录MySQL服务器 select user,host,password from mysql.user;  ← 查看用户信息 set password for root@localhost=password('在这里填入root密码');  ← 设置root密码 select user,host,password from mysql

centOS中mysql一些常用操作

ε祈祈猫儿з 提交于 2019-12-26 23:06:29
安装mysql yum -y install mysql-server 修改mysql配置 vi /etc/my.cnf 这里会有很多需要注意的配置项,后面会有专门的笔记 暂时修改一下编码(添加在密码下方): default-character-set = utf8 设置mysql随系统启动 # chkconfig mysqld on  ← 设置MySQL服务随系统启动自启动 # chkconfig --list mysqld  ← 确认MySQL自启动mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off  ← 如果2--5为on的状态就OK # /etc/rc.d/init.d/mysqld start  ← 启动MySQL服务 显示当前mysql版本和当前日期 select version(),current_date; 修改mysql root密码 # mysql -u root  ← 用root用户登录MySQL服务器 select user,host,password from mysql.user;  ← 查看用户信息 set password for root@localhost=password('在这里填入root密码');  ← 设置root密码 select user,host,password from mysql

mysql数据备份和还原

守給你的承諾、 提交于 2019-12-26 19:12:25
备份结构 1.备份表结构 mysqldump -u root -p -d dbname table1 table2 ... > a.sql 2.备份数据库的所有表结构 mysqldumo -u root -p -d dbname > b.sql 3.备份多个数据库的所有表结构 mysqldump -u root -p -d --databases db1 db2... > c.sql 4.备份所有数据库的表结构 mysqldump -u root -p -d --all-databases > d.sql 备份结构和数据(相当于在备份结构的语法上去掉-d选项) 1.备份表结构和数据 mysqldump -u root -p dbname table1 table2 ... > a.sql 2.备份数据库的所有表结构和数据 mysqldump -u root -p dbname > b.sql 3.备份多个数据库的表结构和数据 mysqldump -u root -p --databases db1 db2 > c.sql 4.备份所有数据库的表结构和数据 mysqldump -u root -p --all-databases > d.sql 备份表数据 select ... into outfile select [列名] from table [where 语句] into