# How to move MySQL8.0 datadir on FreeBSD?



## qscgy4 (Aug 25, 2020)

I tried to modify datadir where at /usr/local/etc/mysql/my.cnf to new path and restarted MySQL.
But when I showed variable of datadir, It was still at original path.





I tried those steps
1.  stop MySQL
1.  `ee /usr/local/etc/mysql/my.cnf`
2.  `datadir=/var/db/mysql` ====> `datadir=/newdir`
3.  `cp -r /var/db/mysql /newdir`
4.  start MySQL
And It doesn't work

Can anyone help me?

Thanks.


----------



## SirDice (Aug 25, 2020)

Read /usr/local/etc/rc.d/mysql-server, you need to set `mysql_dbdir` in rc.conf.


----------



## qscgy4 (Aug 26, 2020)

SirDice said:


> Read /usr/local/etc/rc.d/mysql-server, you need to set `mysql_dbdir` in rc.conf.



Thanks !


----------

