# MySql - Change data folder

**URL:** <https://forums.percona.com/t/mysql-change-data-folder/5377>\
**Category:** Percona Server for MySQL 5.7\
**Created:** [January 27, 2017, 1:24pm UTC](https://forums.percona.com/t/mysql-change-data-folder/5377 "2017-01-27T13:24:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Electivo](https://avatars.discourse-cdn.com/v4/letter/e/77aa72/32.png) [@Electivo](https://forums.percona.com/u/Electivo)\
**Post date:** [January 27, 2017, 1:24pm UTC](https://forums.percona.com/t/mysql-change-data-folder/5377/1 "2017-01-27T13:24:46Z")

</div>

Hello,

I just installed Percona Server 5.7 and want to change the data folder.

I proceeded as follows:

1. I stopped the service - service mysqld stop
2. I edited the /etc/percon-server.conf.d/mysqld.cnf file and changed the new path (datadir = /opt1/mysql-data/mysql)
3. I copied the entire contents of /var/lib/mysql to /opt1/mysql-data/mysql preserving the attributes
4. I tried to restart the database and received the following message:

“Job for mysqld.service failed because the control process exited with error code. See” systemctl status mysqld.service “and” journalctl -xe “for details.”

If I return to the original settings everything returns to normal.

Any suggestion?

Grateful.

---

<div class="post-metadata">

**Author:** ![Ctrl4](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ctrl4/32/32_2.png) [@Ctrl4](https://forums.percona.com/u/Ctrl4)\
**Post date:** [March 12, 2017, 10:36am UTC](https://forums.percona.com/t/mysql-change-data-folder/5377/2 "2017-03-12T10:36:35Z")

</div>

short answer:  
run:

```auto
chcon -R -u system_u -r object_r -t mysqld_db_t

```

Long (and useful) answer can be found in this blog link [URL] [https://phe1129.wordpress.com/2012/04/02/change-mysql-data-folder-on-selinux/[/URL]](https://phe1129.wordpress.com/2012/04/02/change-mysql-data-folder-on-selinux/%5B/URL%5D).
