• 欢迎订阅我的Youtube频道
  • 欢迎加入我的电报群

Migrate your local mysql db to Azure mysql

Uncategorized fennng 2年前 (2018-02-12) 634次浏览 0个评论

Last time, I introduced deploying a new wordpress on azure. But in the real case, you may already have a wordpress running on your local machine with a lot of fancy plugins and some cool pages.

Instead of let wordpress to init an empty database, you may would like to migrate your local mysql database to azure.

I will show you how this can be done.

The first thing is dumping your database to a file. This can be done by using mysqldump command or any other mysql tools such as phpmyadmin.

If you are running mysql in a docker container like what I am doing, use the following command:

docker exec container-name /usr/bin/mysqldump -u root –password=yourpassword wordpress > backup.sql

Or alternatively, you can use phpmyadmin to connect to mysql and export from phpmyadmin

docker run –name tempmyadmin –rm -d –network=wp-net –link wp-mysql:db -p 8060:80 phpmyadmin/phpmyadmin

Then you will need to import your dumped file to azure mysql server. I use phpmyadmin to do this.

docker run –name myadmin -d -e PMA_HOST=azure-dbhost -p 8080:80 phpmyadmin/phpmyadmin

Before importing, you may need to drop the old db and recreate an empty one with phpmyadmin. Once imported, you will need to update the URLs in options table to match the new azure wordpress domain.

Now, back to your wordpress website, you will notice that all the posts and pages appear.

If you have customized your wordpress locally, you may notice that your plugins and customized themes are gone. Because these settings are not in database. You will need to migrate your whole wordpress in your localhost to Azure, I will cover this bit later.


峰享技术 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Migrate your local mysql db to Azure mysql
喜欢 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址