Mysql data directory location

I installed mysql on Mac after downloding its dmg file to version 64 bit. While trying to create a database, he gave me error 1006 - it is impossible to create a database. After browsing several websites, it seems because of setting user rights in the "data directory" directory in mysql, which needs to be changed.

Where is the mysql default data directory? I could not find / var / lib / mysql in localhost.

THANKS.

+67
mysql installation macos
Sep 18 '11 at 2:23
source share
8 answers

See if you have a file located in /etc/my.cnf . If so, he should tell you where the data directory is.

For example:

 [mysqld] set-variable=local-infile=0 datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql ... 

I assume your mysql can be installed in / usr / local / mysql-XXX.

You may find these MySQL manual links useful:

+52
Sep 18 2018-11-11T00:
source share

If the Sequel pro software is installed by default, then mysql on Mac OSX contains the data located here:

 /usr/local/var/mysql 
+47
Jul 28 '14 at 3:03
source share

As I said, I edited this post to respond correctly.

The "physical" location of mysql databases is in / usr / local / mysql

mysql is a symbolic link to the currently active mysql installation, in my case the exact folder is mysql-5.6.10-osx10.7-x86_64.

Inside this folder you will see another data folder, inside which there are RESTRICTED folders with your databases.

In fact, you do not see the size of your databases (this was my problem) from the Finder, because the folder is protected, you can see from the terminal using sudo du -sh /usr/local/mysql/data/{your-database-name} and like this, you get a nice formatted output with size.

In this folder you have different files with all the folders contained in your database, so it is safer to check the db folder to get the size.

What is it. Enjoy it!

+13
Apr 20 '13 at 9:07
source share

Well, if you do not know where my.cnf (such Mac OS X is installed with homegrown), or you are looking for other options:

 ps aux|grep mysql abkrim 1160 0.0 0.2 2913068 26224 ?? R Tue04PM 0:14.63 /usr/local/opt/mariadb/bin/mysqld --basedir=/usr/local/opt/mariadb --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/opt/mariadb/lib/plugin --bind-address=127.0.0.1 --log-error=/usr/local/var/mysql/iMac-2.local.err --pid-file=iMac-2.local.pid 

You get datadir=/usr/local/var/mysql

+8
Jun 15 '17 at 10:49 on
source share

Check where the mysql root folder is located:

 mysql_config 
+7
Dec 14 '14 at 2:13
source share

If you are using macOS {mine 'High Sierra'} and installed XAMPP

You can find mysql data files;

Go to: /Applications/XAMPP/xamppfiles/var/mysql/

+1
Feb 09 '18 at 9:02
source share

If you use Homebrew to install MySQL@5.7, the location

 /usr/local/Homebrew/var/mysql 

I do not know if the location is the same for other versions.

0
May 08 '19 at 10:59
source share

If you install MySQL using homebrew on MacOS, you may need to delete the old data directory /usr/local/var/mysql . Otherwise, it will fail during the initialization process with the following error:

 ==> /usr/local/Cellar/mysql/8.0.16/bin/mysqld --initialize-insecure --user=hohoho --basedir=/usr/local/Cellar/mysql/8.0.16 --datadir=/usr/local/var/mysql --tmpdir=/tmp 2019-07-17T16:30:51.828887Z 0 [System] [MY-013169] [Server] /usr/local/Cellar/mysql/8.0.16/bin/mysqld (mysqld 8.0.16) initializing of server in progress as process 93487 2019-07-17T16:30:51.830375Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting. 2019-07-17T16:30:51.830381Z 0 [ERROR] [MY-013236] [Server] Newly created data directory /usr/local/var/mysql/ is unusable. You can safely remove it. 2019-07-17T16:30:51.830410Z 0 [ERROR] [MY-010119] [Server] Aborting 2019-07-17T16:30:51.830540Z 0 [System] [MY-010910] [Server] /usr/local/Cellar/mysql/8.0.16/bin/mysqld: Shutdown complete (mysqld 8.0.16) Homebrew. 
0
Jul 17 '19 at 16:37
source share



All Articles