Server version: 5.7.20-0ubuntu0.16.04.1 (Ubuntu)
After logging into MySQL, you can use the following command to query where the related files are stored:
show variables like '%dir%';
The output is shown below:

Usually these are:
The default location of the database files is: /usr/share/mysql/
Configuration file: /etc/mysql/my.cnf
Database directory: /var/lib/mysql
Configuration directory: /etc/share/mysql (mysql.server command and configuration files)
MySQL related commands: /usr/bin
Startup scripts: /etc/init.d/
One way to start mysql safely: /usr/bin/mysqld_safe-user=root&