Wednesday, January 5, 2022

[SOLVED] Where is the BASEDIR for MySQL installed with APT on Ubuntu?

Issue

According to the MySQL document, 2.10.1 Initializing the Data Directory:

  1. Change location into the top-level directory of your MySQL installation, represented here by BASEDIR:

    shell> cd BASEDIR

    BASEDIR is likely to be something like /usr/local/mysql or /usr/local. The following steps assume that you have changed location to this directory.

    You will find several files and subdirectories in the BASEDIR directory. The most important for installation purposes is the bin subdirectory, which contains the server as well as client and utility programs.

I've checked /usr/local/mysql and /usr/local, but neither of them contains anything related to MySQL. which mysql returns /usr/bin/mysql, but I don't think /usr/bin would be MySQL's base directory.

The document says I need to create a directory called mysql-files under BASEDIR, so I want to know where to find it.


Solution

First of all, you can find the files installed by an Apt package using dpkg -L name, for example:

dpkg -L mysql-server-5.6

As you will see, there is no clear BASEDIR where all the MySQL server files reside. The files are spread out at multiple locations. So this reference point mentioned in the documentation you linked doesn't apply well to systems like Ubuntu.

You can create the directory somewhere in the system and then set secure_file_priv to the absolute path of that location. I don't know what is the recommended location for this in Ubuntu, but probably somewhere under /var/lib/mysql should be good.



Answered By - janos