MySQL mysql数据目录位置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7459103/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 21:05:59  来源:igfitidea点击:

mysql data directory location

mysqlmacosinstallation

提问by iwan

I installed mysql in Mac after downloding its dmg file version 64 bit. While trying to create a database it gave me error 1006 -- can't create database. After browsing a number of website, it seems due to user ownership setting of mysql "data directory" location that needs to be changed.

下载 64 位 dmg 文件版本后,我在 Mac 中安装了 mysql。在尝试创建数据库时,它给了我错误 1006 -- 无法创建数据库。浏览了多个网站后,似乎是由于mysql“数据目录”位置的用户所有权设置需要更改。

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

mysql默认的“数据目录”在哪里?我在本地主机中找不到 /var/lib/mysql。

THANKS.

谢谢。

采纳答案by paulsm4

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

看看您是否有位于/etc/my.cnf. 如果是这样,它应该告诉您数据目录在哪里。

For example:

例如:

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

My guess is that your mysql might be installed to /usr/local/mysql-XXX.

我的猜测是您的 mysql 可能安装到 /usr/local/mysql-XXX。

You may find these MySQL reference manual links useful:

您可能会发现这些 MySQL 参考手册链接很有用:

回答by nextzeus

If the software is Sequel pro the default install mysql on Mac OSX has data located here:

如果该软件是 Sequel pro,则 Mac OSX 上的默认安装 mysql 的数据位于此处:

/usr/local/var/mysql

回答by Arthur Kovacs

As suggested, I edited this message to place a proper answer.

按照建议,我编辑了这条消息以给出正确的答案。

The 'physical' location of the mysql databases are under /usr/local/mysql

mysql 数据库的“物理”位置在 /usr/local/mysql 下

the mysql is a symlink to the current active mysql installation, in my case the exact folder is mysql-5.6.10-osx10.7-x86_64.

mysql 是当前活动 mysql 安装的符号链接,在我的情况下,确切的文件夹是 mysql-5.6.10-osx10.7-x86_64。

Inside that folder you'll see another data folder, inside it are RESTRICTED folders with your databases.

在该文件夹中,您将看到另一个数据文件夹,其中包含您的数据库的 RESTRICTED 文件夹。

You can't actually see the size of your databases (that was my issue) from the Finder because the folder are protected, you can though see from the terminal with sudo du -sh /usr/local/mysql/data/{your-database-name}and like this you'll get a nice formatted output with the size.

您实际上无法从 Finder 看到数据库的大小(那是我的问题),因为文件夹受到保护,但您可以从终端看到sudo du -sh /usr/local/mysql/data/{your-database-name},像这样,您将获得带有大小的漂亮格式化输出。

In those folder you have different files with all the folders present in your database, so it's safer to check the db's folder to get a size.

在这些文件夹中,您有不同的文件,其中包含数据库中存在的所有文件夹,因此检查 db 的文件夹以获取大小更安全。

That's it. Enjoy!

就是这样。享受!

回答by abkrim

Well, if yo don't know where is my.cnf (such Mac OS X installed with homebrew), or You are looking found others choices:

好吧,如果您不知道 my.cnf 在哪里(例如安装了自制软件的 Mac OS X),或者您正在寻找其他选择:

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

你得到 datadir=/usr/local/var/mysql

回答by Julio Marins

Check where is the root folder of mysql with:

检查mysql的根文件夹在哪里:

mysql_config

回答by Elshan

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

如果您使用的是macOS {mine 'High Sierra'}并安装了 XAMPP

You can find mysql data files;

可以找到mysql数据文件;

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

去 : /Applications/XAMPP/xamppfiles/var/mysql/

回答by Aerendir

If you are using Homebrew to install [email protected], the location is

如果你使用 Homebrew 安装 [email protected],位置是

/usr/local/Homebrew/var/mysql

I don't know if the location is the same for other versions.

我不知道其他版本的位置是否相同。

回答by ck1910

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

如果您在 MacOS 上通过自制软件安装 MySQL,您可能需要删除旧的数据目录/usr/local/var/mysql。否则,它会在初始化过程中失败并出现以下错误:

==> /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.