# Copying a remote MySQL Database

**URL:** <https://forum.ansible.com/t/copying-a-remote-mysql-database/19799>\
**Category:** Ansible Project\
**Created:** [November 18, 2015, 10:01pm UTC](https://forum.ansible.com/t/copying-a-remote-mysql-database/19799 "2015-11-18T22:01:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven\_Parsons](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@Steven\_Parsons](https://forum.ansible.com/u/Steven_Parsons)\
**Post date:** [November 18, 2015, 10:01pm UTC](https://forum.ansible.com/t/copying-a-remote-mysql-database/19799/1 "2015-11-18T22:01:21Z")

</div>

I am wondering if anyone has copied a MySQL database from a location and then restored it locally using Ansible? I thought I had it figured out with the following syntax, but for some reason its failing.

`

- name: Install python-mysqldb  
apt: name=python-mysqldb state=latest

- name: Copy MySQL Database  
mysql\_db: login\_host=[onthe.web.net](http://onthe.web.net) login\_user=someone login\_password=cheese state=dump name=cheese target=/tmp/cheese.sql  
mysql\_db: state=import name=cheese target=/tmp/cheese.sql  
`

Any help would be appreciated.

Steven

---

<div class="post-metadata">

**Author:** ![Dick\_Davies](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Dick\_Davies](https://forum.ansible.com/u/Dick_Davies)\
**Post date:** [November 19, 2015, 1:59pm UTC](https://forum.ansible.com/t/copying-a-remote-mysql-database/19799/2 "2015-11-19T13:59:51Z")

</div>

split ‘Copy MySQL Database’ into two separate tasks, with one action each.

---

<div class="post-metadata">

**Author:** ![Steven\_Parsons](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@Steven\_Parsons](https://forum.ansible.com/u/Steven_Parsons)\
**Post date:** [November 19, 2015, 9:55pm UTC](https://forum.ansible.com/t/copying-a-remote-mysql-database/19799/3 "2015-11-19T21:55:41Z")

</div>

Awesome that worked, thanks for the help.

Steven
