# How can I change my mysql8 data directory in freebsd ?



## tonychang0986 (Oct 2, 2021)

Hi all:
How can I change my mysql8 data directory in freebsd ? I want to change mysql default directory.
old directory is SSD /var/db/mysql  , The new  path is another mount point SAS HD  /newdata/mysql

I  search google following example, right? 
I find​


----------



## SirDice (Oct 4, 2021)

tonychang0986 said:


> How can I change my mysql8 data directory in freebsd ?


Set `mysql_dbdir` in /etc/rc.conf:

```
# mysql_enable (bool):	Set to "NO" by default.
#			Set it to "YES" to enable MySQL.
# mysql_dbdir (str):	Default to "/var/db/mysql"
#			Base database directory.
# mysql_confdir (str):	Default to "/usr/local/etc/mysql"
#			Base configuration directory.
# mysql_optfile (str):	Server-specific option file.
#			Set it in the rc.conf or default behaviour of
#			`mysqld_safe` itself, will be picking
#			${mysql_confdir}/my.cnf if it exists.
# mysql_pidfile (str):	Custum PID file path and name.
#			Default to "${mysql_dbdir}/${hostname}.pid".
# mysql_args (str):	Custom additional arguments to be passed
#			to mysqld_safe (default empty).
```


----------

