My favorite way is to pipe a sqldump command to a sql command. You can do all databases or a specific one. So, for instance,
mysqldump -uuser -ppassword myDatabase | mysql -hremoteserver -uremoteuser -premoteserverpassword
You can do all databases with
mysqldump --all-databases -uuser -ppassword | mysql -hremoteserver -uremoteuser -premoteserver
The only problem is when the database is too big and the pipe collapses. In that case, you can do table by table or any of the other methods mentioned below.
=======================
I recently moved a 30GB database with the following stragegy:
Old Server
- Stop mysql server
- Copy contents of datadir to another location on disk (
~/mysqldata/*
) - Start mysql server again (downtime was 10-15 minutes)
- compress the data (
tar -czvf mysqldata.tar.gz ~/mysqldata
) - copy the compressed file to new server
New Server
- install mysql (don't start)
- unzip compressed file (
tar -xzvf mysqldata.tar.gz
) - move contents of mysqldata to the datadir
- Make sure your innodb_log_file_size is same on new server, or if it's not, don't copy the old log files (mysql will generate these)
- Start mysql
=======================
You don't even need mysqldump if you're moving a whole database schema, and you're willing to stop the first database (so it's consistent when being transfered)
- Stop the database (or lock it)
- Go to the directory where the mysql data files are.
- Transfer over the folder (and its contents) over to the new server's mysql data directory
- Start back up the database
- On the new server, issue a 'create database' command.'
- Re-create the users & grant permissions.
I can't remember if mysqldump handles users and permissions, or just the data ... but even if it does, this is way faster than doing a dump & running it. I'd only use that if I needed to dump a mysql database to then re-insert into some other RDBMS, if I needed to change storage options (innodb vs. myisam), or maybe if I was changing major versins of mysql (but I think I've done this between 4 & 5, though)
=======================
=======================
REF:
https://dba.stackexchange.com/questions/174/how-can-i-move-a-database-from-one-server-to-another
How can I move a MySQL database from one server to another?的更多相关文章
-
How to Baskup and Restore a MySQL database
If you're storing anything in MySQL databases that you do not want to lose, it is very important to ...
-
How To Move a MySQL Data Directory to a New Location on Ubuntu 16.04
16 How To Move a MySQL Data Directory to a New Location on Ubuntu 16.04 PostedJuly 21, 2016 62.1kvie ...
-
Backup and Restore MySQL Database using mysqlhotcopy
mysqlhotcopy is a perl script that comes with MySQL installation. This locks the table, flush the ta ...
-
Writing to a MySQL database from SSIS
Writing to a MySQL database from SSIS 出处 : http://blogs.msdn.com/b/mattm/archive/2009/01/07/writin ...
-
MySQL Database on Azure新功能
本月中国版的MySQL Database on Azure发布了两项新功能: 1.主从复制——只读实例 在这之前Azure上的MySQL数据库也是支持主从复制的,但是只能作为on-premises部署 ...
-
CentOS 7 安装 MySQL Database
CentOS 7 安装 MySQL Database 1. 现在安装包,MySQL的安装包被分成了社区版和企业版,而本文将记录社区版本MySQL安装过程,下载MySQL版本如下: mysql-5.7. ...
-
mysql-databaseython 3.4.0 with MySQL database
Phttp://shttp://*.com/questions/23376103/python-3-4-0-with-mysql-databasetackoverflow.co ...
-
MySQL Database on Azure
在国际版的Microsoft Azure上,MySQL服务是与ClearDB合作运营的.由于ClearDB无法在中国地区提供服务,因此微软中国的研发团队开发了专门面向中国市场的MySQL Databa ...
-
MySQL Database on Azure 参数设置
在使用MySQL过程中,经常会根据需要对MySQL的参数进行一些设置和调整.作为PaaS版本的MySQL,MySQL Database on Azure在参数设置方面有一些限制,客户不能像使用on-p ...
随机推荐
-
Mysql事务探索及其在Django中的实践(二)
继上一篇<Mysql事务探索及其在Django中的实践(一)>交代完问题的背景和Mysql事务基础后,这一篇主要想介绍一下事务在Django中的使用以及实际应用给我们带来的效率提升. 首先 ...
-
javascript变量声明 及作用域
javascript变量声明提升(hoisting) http://openwares.net/js/javascript_declaration_hoisting.html 可能要FQ一下 java ...
-
Linux之硬件管理(不断更新中)
1 查看CPU信息 [root@limt01 .ssh]# lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64- ...
-
jquery validate.js表单验证的基本用法入门
这里转载一篇前辈写的文章,在我自己的理解上修改了一下,仅作记录. 先贴一个国内某大公司的代码: 复制代码 代码如下: <script type="text/javascript&quo ...
-
ajax大数据排队导出+进度条
描述 :我们现在有很多数据,分表存放,现在需要有精度条的导出.最后面有完整源码. 效果图:
-
Android学习手记(3) Activity间传递数据
1. 简单数据传递 建立两个Activity,名称分别为MainActivity和TheAty,在MainActivity中新建一个Button,id为btnStartAty.在TheAty中新建一个 ...
-
HDU 5729 - Rigid Frameworks
题意: 对于一个由n*m个1*1的菱形组成可任意扭曲的矩形(姑且这么说),求添加斜线*(两种)让菱形变成正方形,使得整个矩形固定且无法扭曲的方案数. 分析: n*m的矩形有如下性质:( 平 ...
-
我的Android 4 学习系列之文件、保存状态和首选项
目录 使用Shared Preference 保留简单的应用程序数据 保存回话间的Activity实例数据 管理应用程序首选项和创建Preference Screen 保存并加载文件以及管理本地文件系 ...
-
R12: Improving Performance of General Ledger and Journal Import (Doc ID 858725.1 )
In this Document Purpose Scope Details A) Database Init.ora Parameters B) Concurrent Progr ...
-
BZOJ_4003_[JLOI2015]城池攻占_可并堆
BZOJ_4003_[JLOI2015]城池攻占_可并堆 Description 小铭铭最近获得了一副新的桌游,游戏中需要用 m 个骑士攻占 n 个城池. 这 n 个城池用 1 到 n 的整数表示.除 ...