mysqldump

Linux系统Mysql备份的导入导出

别说谁变了你拦得住时间么 提交于 2019-12-02 07:34:15
Mysql 备份 如果您使用的是帮助中心的一键环境配置,mysql的安装目录是/alidata/server/mysql,如果您将mysql安装到其他目录,您需要输入您mysql完整的安装路径。 单库备份您可以在服务器上执行/alidata/server/mysql/bin/mysqldump -uroot -p密码 数据库名 > 备份名称.sql mysqldump默认不会导出事件表,执行此命令会出现警告-- Warning: Skipping the data of table mysql.event. Specify the --events option explicitly. 如果您需要导出mysql事件,您可以执行/alidata/server/mysql/bin/mysqldump -uroot -p密码 --events --ignore-table=mysql.event 数据库名 > beifen.sql 导入与恢复 如果您需要导入您在其他服务器上导出或您备份的.sql文件,您可以在备份.sql文件所在目录中执行/alidata/server/mysql/bin/mysql -uroot -p密码 mysql < beifen.sql 进行导入恢复。 也可以通过/alidata/server/mysql/bin/mysql -uroot -p密码 进入mysql

python subprocess and mysqldump

三世轮回 提交于 2019-12-02 07:24:18
问题 I know parts of this question have been asked before, but I have some related questions. I'm trying to execute mysqldump -u uname -ppassword --add-drop-database --databases databaseName | gzip > fileName I'm potentially dumping a very large (200GB?) db. Is that in itself a dumb thing to do? I then want to send the zipped file over the network for storage, delete the local dump, and purge a couple of tables. Anyway, I was using subprocess like this, because there doesn't seem to be a way to

二十四、mysql数据备份与还原

左心房为你撑大大i 提交于 2019-12-02 06:17:08
数据表备份与还原 备份: 将当前已有的数据或者记录保留。 还原: 将已经保留的数据恢复到对应的表中。 做备份和还原的原因: 防止数据丢失 被盗、误删除等 保护数据记录 数据备份还原的方式有: 数据表备份、单表数据备份、SQL备份、增量备份。 数据表备份 定义: 不需要通过SQL来备份,直接进入到数据库文件夹复制对应的表结构及数据文件,以后还原的时候,直接将备份的内容放进去即可。 数据表备份有前提条件, 根据不同的存储引擎有不同的区别; 存储引擎: mysql进行数据存储的方式,主要是innodb和myisam两种; 各种存储引擎简介如下图: myisam和innodb存储引擎的对比: innodb只有表结构,数据全部存储到idbatal文件中;而myisam表数据和索引全部单独分开存储,其中.frm是结构文件,.myd是数据,.myi是索引,这种文件备份通常适用于myisam引擎,直接复制三个文件即可;而innodb的数据表是依赖于数据库的,不能单独拿出一个表进行使用; 单表数据备份 定义: 每次只能备份一张表,只能备份数据(表结构不能备份),通常的使用是将表的数据进行导出,导出到文件; 基本的备份操作: 从表中选出一部分数据保存到外部的文件中(outfile) 基本语法: select */字段列表 into outfile 文件所在路径 from 数据源; 注意事项

MySQL Syntax error when locally importing dump from Amazon MySQL RDS?

跟風遠走 提交于 2019-12-02 06:06:32
When I create a database dump from Amazon RDS and then I try to import it locally, the result is ERROR 1064 (42000) at line 54 . At line 54 there is the following statement: CREATE TABLE account_emailconfirmation ( The command used for dump is: mysqldump -u user -h host.rds.amazonaws.com -p --default-character-set=utf8 --result-file=sync.sql database_name The command used for import is: mysql --user=root -p mpl -vv < sync.sql And here is the output (verbosity increased). -------------- CREATE TABLE `account_emailconfirmation` ( `id` int(11) NOT NULL AUTO_INCREMENT, `created` datetime(6) NOT

【MySQL】备份和恢复

落爺英雄遲暮 提交于 2019-12-02 04:48:12
语法 mysqldump -uslave -p -h127.0.0.1 --set-gtid-purged=OFF database1 table1 table2 table3 >db.sql 摘录 导出整个数据库(包括数据库中的数据) mysqldump -u username -p dbname > dbname.sql 导出某些库 mysqldump -uusername -ppassword --databases db1 db2 > db1db2.sql 导出数据库结构(不含数据) mysqldump -u username -p -d dbname > dbname.sql 导出数据库中的某张数据表(包含数据) mysqldump -u username -p dbname tablename > tablename.sql 导出数据库中的某张数据表的表结构(不含数据) mysqldump -u username -p -d dbname tablename > tablename.sql 将备份文件压缩: mysqldump -hhostname -uusername -ppassword --databases dbname | gzip > backup-file.sql.gz 导入数据库: mysql> use target_dbname mysql>

will show table status display exact rows in the table?

拟墨画扇 提交于 2019-12-02 03:52:05
I have a table in DB and it is approx 90 GB in space. I tried to count no of rows in the table select count(idNewsNotification) from notification and it resulted 4982397 1 row in set (59 min 48.35 sec) But when I queried using show table status like <table_name> it is showing that Engine: InnoDB Version: 10 Row_format: Compact Rows: 8631267 Avg_row_length: 11237 Data_length: 96996425728 Max_data_length: 0 Index_length: 175374336 Data_free: 0 Auto_increment: NULL ..... What is the perfect procedure for knowing the no of records in the table ? The fact that your count took an hour implies that

MySQL语句大全

送分小仙女□ 提交于 2019-12-02 02:28:13
MySQL语句大全 https://www.cnblogs.com/jicki/p/5548676.html 一、连接mysql。 格式: mysql -h主机地址 -u用户名 -p用户密码 二、修改密码。 格式:mysqladmin -u用户名 -p旧密码 password 新密码 1、给root加个密码ab12。首先在DOS下进入目录mysql\bin,然后键入以下命令 mysqladmin -u root -password ab12 注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。 2、再将root的密码改为djg345。 mysqladmin -u root -p ab12 password djg345 三、增加新用户。 (注意:和上面不同,下面的因为是MYSQL环境中的命令,所以后面都带一个分号作为命令结束符) 格式:grant select on 数据库.* to 用户名@登录主机 identified by "密码" 1、增加一个用户test1密码为abc,让他可以在任何主机上登录,并对所有数据库有查询、插入、修改、删除的权限。首先用root用户连入MYSQL,然后键入以下命令: grant select,insert,update,delete on *.* to test1@"%" Identified by "abc"; 创建所有权限的帐号:

mysqldump on remote server

不打扰是莪最后的温柔 提交于 2019-12-02 02:27:41
问题 If there are two machines client and server .From client how to do a mysqldump to the server such that the dump is avaliable on the client and not stored in the server Thanks.. 回答1: Here is a PHP script that generates a mysqldump. It outputs directly to the client, and does not create any files on the server. https://github.com/tylerl/web-scripts/tree/master/mysqldump 回答2: Do this in two steps: dump data on server transfer to client (possibly compress first) If you need to do it often, then

mysqldump without database name

筅森魡賤 提交于 2019-12-02 01:39:45
问题 Is it possible to dump data in xml format without the database name in the output? If I dump output like this with the --xml option: $>mysqldump --xml my_database_name my_table > my_table.xml Then my output is something like <?xml version="1.0"?> <mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <database name="my_database_name"> ... You can see the database name in the output which I do not want. Is there an option to prevent that? 回答1: I don't think there is such option for

Local replica of RDS database

一个人想着一个人 提交于 2019-12-02 00:57:00
问题 I've been doing some research for the past hour or so and I've been hearing some conflicting information regarding the replication of Amazon RDS databases. My database is pretty big, 15 tables with a total size of 4 GB. So, basically, is it possible for me to create a local replica of a remote RDS InnoDB or does Amazon not allow it? 回答1: you can create replicas of an RDS but only as another RDS. You can't do a replica on an EC2 or a local machine. 来源: https://stackoverflow.com/questions