mysqldump

MYSQL 导入导出数据库文件

戏子无情 提交于 2019-12-02 19:36:17
MYSQL 导入导出数据库文件 一、从数据库导出数据库或表文件: mysqldump -u用戶名 -p密码 -d 数据库名 表名 > 脚本名; 导出整个数据库结构和数据 mysqldump -h localhost -uroot -p123456 database > e:\dump.sql 导出单个数据表结构和数据 mysqldump -h localhost -uroot -p123456 database table > e:\dump.sql 导出整个数据库结构(不包含数据) mysqldump -h localhost -uroot -p123456 -d database > e:\dump.sql 导出单个数据表结构(不包含数据) mysqldump -h localhost -uroot -p123456 -d database table > e:\dump.sql 二、导入数据库或表到数据库(数据库要先建好) 方法1:mysql -h localhost -uroot -p123456 -d database table < e:\dump.sql 方法2: 1.进入MySQL:mysql -u root -p 2.输入:use 目标数据库名 3.导入文件:source e:\dump.sql 一、从数据库导出数据库或表文件: mysqldump -u用戶名

Is there a faster way to load mysqldumps? [duplicate]

放肆的年华 提交于 2019-12-02 19:13:51
Possible Duplicate: Speeding up mysql dumps and imports mysqldump is reasonably fast, but dumps of a medium-sized database (20-30 megs) take several minutes to load using mysql my_database < my_dump_file.sql Are there some mysql settings I can tune to speed up the load? Is there a better way to load saved data? I've experimented using the mysqlimport utility with CSV-based dumps. These load slightly--but not appreciably--faster. I'm tempted to just copy raw database files around, but that seems like a bad idea. maatkit - parallel dump and maatkit - parallel restore Very fast. Assuming that you

记一次gogs迁徙

假如想象 提交于 2019-12-02 18:51:20
因有台服务器快到期,也不想续费了。逐渐把上面的功能往其它服务器上转移。这次转移的功能是gogs,一个基于golong开发的git服务器。 目标:从old.com 迁移到 main.com 需要操作的对象:相关文件,mysql数据 工具:scp mysqldump 先是把服务停了,然后根据pid kill掉进程 ps aux | grep gogdsudo kill -9 XXXX 然后把文件从old.com迁移到main.com上去 gogs主要有两个文件夹 gogs gogs-repositories 因此先打包,在old.com下操作 cd ~/document zip -r gogs.bak.zip ./gogs zip -r gogs-repos.bak.zip ./gogs-repositories 然后通过mysqldump命令把gogs数据库生成.sql文件 mysqldump -u user -p --batabases gogs > ~/document/gogs.sql 在main.com下新建目录,进入目录后把zip文件从old.com 通过scp迁移到main.com中 在main.com下操作 mkdir /gogsrootcd gogsrootscp user@old.com:/admin/document/gogs.bak.zip

How do I use mysqldump to export only the CREATE TABLE commands?

ぐ巨炮叔叔 提交于 2019-12-02 18:48:48
I'm trying to use mysqldump to export only the DB schema -- no data, no additional SQL comments, just the CREATE TABLE commands. Here's what I've got so far: mysqldump -h localhost -u root -p --no-data --compact some_db It almost achieves what I want, but I'd like to eliminate the "character set" lines (those like the first 3 lines in the example output below). Is there a mysqldump option to do that? /*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `foo` ( `id` int(11)

While importing mysqldump file ERROR 1064 (42000) near ' ■/ ' at line 1

风格不统一 提交于 2019-12-02 18:45:16
Cannot import the below dump file created by mysqldump.exe in command line of windows /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `attachment_types` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `DESCRIPTION` varchar(50) DEFAULT NULL, `COMMENTS` varchar(256) DEFAULT NULL, PRIMARY KEY (`ID`), UNIQUE KEY `UK_ATTACHMENT_TYPES___DESCRIPTION` (`DESCRIPTION`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; While importing the file in command line mysql --user=root --password=root < mysqldumpfile.sql It throws error ERROR

Compare structures of two databases?

蓝咒 提交于 2019-12-02 18:10:25
I wanted to ask whether it is possible to compare the complete database structure of two huge databases. We have two databases, the one is a development database, the other a production database. I've sometimes forgotten to make changes in to the production database, before we released some parts of our code, which results that the production database doesn't have the same structure, so if we release something we got some errors. Is there a way to compare the two, or synchronize? What about http://www.mysqldiff.org/ which is freeware? You can use the command line: mysqldump --skip-comments -

How to use mysqlimport to read in result of mysqldump --databases

旧巷老猫 提交于 2019-12-02 18:08:48
I have successfully dumped an entire MySQL database using mysqldump --databases generating a nice .txt file. However, I can't see how to read the whole file back into MySQL in one go; mysqlimport seems to want just one table at a time. When you've generated some file (say db-dump.sql ) with mysqldump , you can import it to your other database with the mysql command : mysql --user=XXX --password=XXX --host=YOUR_HOST DATABASE_NAME < db-dump.sql And, if you don't want the password to appear in a command, you can use : mysql --user=XXX -p --host=YOUR_HOST DATABASE_NAME < db-dump.sql As a sidenote,

Using mysqldump to format one insert per line?

只愿长相守 提交于 2019-12-02 17:24:48
This has been asked a few times but I cannot find a resolution to my problem. Basically when using mysqldump, which is the built in tool for the MySQL Workbench administration tool, when I dump a database using extended inserts, I get massive long lines of data. I understand why it does this, as it speeds inserts by inserting the data as one command (especially on InnoDB), but the formatting makes it REALLY difficult to actually look at the data in a dump file, or compare two files with a diff tool if you are storing them in version control etc. In my case I am storing them in version control

MySQL导入.sql文件及常用命令

落花浮王杯 提交于 2019-12-02 15:24:58
在MySQL Qurey Brower中直接导入*.sql脚本,是不能一次执行多条sql命令的,在mysql中执行sql文件的命令: mysql> source d:/myprogram/database/db.sql; 另附mysql常用命令: 一) 连接MYSQL: 格式: mysql -h主机地址 -u用户名 -p用户密码 1、例1:连接到本机上的MYSQL 首先在打开DOS窗口,然后进入mysql安装目录下的bin目录下,例如: D:/mysql/bin,再键入命令mysql -uroot -p,回车后提示你输密码,如果刚安装好MYSQL,超级用户root是没有密码的,故直接回车即可进入到MYSQL中了,MYSQL的提示符 是:mysql> 2、例2:连接到远程主机上的MYSQL (远程:IP地址) 假设远程主机的IP为:10.0.0.1,用户名为root,密码为123。则键入以下命令: mysql -h10.0.0.1 -uroot -p123 (注:u与root可以不用加空格,其它也一样) 3、退出MYSQL命令 exit (回车) (二) 修改密码: 格式:mysqladmin -u用户名 -p旧密码 password 新密码 1、例1:给root加个密码123。首先在DOS下进入目录C:/mysql/bin,然后键入以下命令: mysqladmin -uroot

mysqldump entire structure but only data from selected tables in a single command

一世执手 提交于 2019-12-02 14:31:02
My database has 3 tables: table1, table2 and table3 I would like to do a mysqldump on this database with the following conditions: Dump structure for all tables Only dump data for table1 and table2, ignore data in table3 Currently, I do this with 2 mysqldump statements mysqldump -u user -p -d db > db_structure.sql mysqldump -u user -p db --ignore-table=db.table3 > table1_and_table2_data.sql Import them in the same order they were dumped (structure, then data from table1 and table2) Is there a way to combine this into a single mysqldump command? Cfreak You can't combine them in one command but