How to change the location of database files in MySQL 8.0?

On my comp installed the MySQL server is 8.0. For the database file has been allocated a separate HDD. How to make files of this database lying on a new separate hard drive, and the MySQL server remains on the old disk? Need to on the new drive was the ONLY one with the database files without any garbage.
June 5th 19 at 21:12
3 answers
June 5th 19 at 21:14
- gracefully stop the database
- make sure that the base is not running
- copy the entire datadir (see mysql configuration file) to new location
- change datadir in the config to the new location
- start database
- verify and to demolish the old datadir
The fact that in the datadir in addition to daddy with the name base is still a bunch of all debris not directly related to the database. - ethelyn commented on June 5th 19 at 21:17
still as relevant. - Ignacio_Romaguera commented on June 5th 19 at 21:20
June 5th 19 at 21:16
File my.cnf
datadir=/data/mysql - write path where you want to go
June 5th 19 at 21:18
Option --datadir, it also is in the config.
System variable datadir

Find more questions by tags MySQL