is it safe to create mysql database by just creating its directory?
UNSAFE!
Use CREATE DATABASE.

mkdir probably works for ENGINE=MyISAM, but that old engine should not be used anymore.
InnoDB needs to know what is going on.
You noticed db.opt; but what if something else gets added in the future?
MySQL 8.0 has an internal &quot;data dictionary&quot; that would be totally confused by that mkdir.
And who knows what future versions will be like !

It is possible to execute a command on the mysql commandline tool.  This makes CREATE DATABASE a one-liner, albeit more verbose than a simple mkdir.
If you want a table or partition to be on a different physical drive, check out the limited capabilities of specifying the location for the DATA DIRECTORY:  https://dev.mysql.com/doc/refman/8.0/en/innodb-create-table-external.html