nalzok
nalzok

Reputation: 16137

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

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.

Upvotes: 3

Views: 12109

Answers (4)

     Юрий Светлов
Юрий Светлов

Reputation: 1750

For some MySQL installation methods, data directory initialization is automatic For APT on Ubuntu - automatic initialization in /usr/bin/ it is basedir


/usr/bin/

mysql
mysqladmin
mysqldump
mysqlpump
mysqlshow
mysqlslap
mysqlcheck
mysqlbinlog
mysqld_safe
mysqlimport
mysqld_multi
mysqldumpslow
mysql_upgrade
mysql_config_editor
mysql_ssl_rsa_setup
mysql_tzinfo_to_sql
mysql_secure_installation

/usr/sbin/

mysqld

/usr/lib/mysql/

/plugin/

/private/

/var/lib/mysql/

it is datadir

/var/log/mysql/

error.log

/etc/mysql/mysql.conf.d/

mysqld.cnf

/var/lib/mysql-files/


/var/lib/mysql-keyring/


/etc/systemd/system/multi-user.target.wants/

mysql.service

/home/name_account_pc

.mysql_history

Upvotes: 0

Daniel Viglione
Daniel Viglione

Reputation: 9487

The following will work in Ubuntu, any linux distro for that matter, OS X and pretty much any OS supporting mysql:

$ mysqladmin -u root variables | grep basedir

Upvotes: 0

Michael - sqlbot
Michael - sqlbot

Reputation: 179374

The base directory is a system varible, so if you want to know what it is, you should be able to simply ask the running server:

mysql> SELECT @@BASEDIR;

https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_basedir

Upvotes: 4

janos
janos

Reputation: 124804

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.

Upvotes: 1

Related Questions