mysql 在哪里存储数据?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26402884/
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
Where does mysql store data?
提问by Konrad
Where does mysql store data? I found out (by using mysql>SELECT @@datadir ) that it's in var/lib/mysql - but that can't be it. I have a quite big database (4 GB) called 'bot', but all the files in the 'bot' subdirectory (var/lib/mysql/bot) have only 280KB. Where is the rest?
mysql 在哪里存储数据?我发现(通过使用 mysql>SELECT @@datadir )它在 var/lib/mysql 中 - 但这不可能。我有一个名为“bot”的相当大的数据库 (4 GB),但“bot”子目录 (var/lib/mysql/bot) 中的所有文件只有 280KB。剩下的在哪里?
One more thing - 99% of the database's size is a text column in one of the tables - I know that mysql stores it in separate files, but does it create one file per record?
另一件事 - 数据库大小的 99% 是其中一个表中的文本列 - 我知道 mysql 将它存储在单独的文件中,但它是否为每条记录创建一个文件?
I found a big file in the var/lib/mysql directory named ibdata1 - its size is over 8GB - what is it? (btw, there are other databases as well in the var/lib/mysql directory).
我在 var/lib/mysql 目录中发现了一个名为 ibdata1 的大文件 - 它的大小超过 8GB - 它是什么?(顺便说一句,var/lib/mysql 目录中还有其他数据库)。
采纳答案by Giles
Reading between the lines - Is this an innodb database? In which case the actual data is normally stored in that directory under the name ibdata1. This file contains all your tables unless you specifically set up mysql to use one-file-per-table (innodb-file-per-table)
字里行间——这是一个innodb数据库吗?在这种情况下,实际数据通常以名称 ibdata1 存储在该目录中。该文件包含您的所有表,除非您专门设置 mysql 以使用每个表一个文件(innodb-file-per-table)
回答by duDE
From here:
从这里:
Windows
视窗
1) Locate the my.ini, which store in the MySQL installation folder.
1) 找到my.ini,它存储在MySQL 安装文件夹中。
For Example, C:\Program Files\MySQL\MySQL Server 5.1\my.ini
例如, C:\Program Files\MySQL\MySQL Server 5.1\my.ini
2) Open the “my.ini” with our favor text editor.
2) 用我们喜欢的文本编辑器打开“my.ini”。
#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 5.1/"
#Path to the database root
datadir="C:/Documents and Settings/All Users/Application Data/MySQL/MySQL Server 5.1/Data/"
Find the “datadir”
, this is the where does MySQL stored the data in Windows.
找到“datadir”
,这是 MySQL 在 Windows 中存储数据的位置。
Linux
Linux
1) Locate the my.cnf with the find / -name my.cnf command.
1) 使用 find / -name my.cnf 命令找到 my.cnf。
yongmo@myserver:~$ find / -name my.cnf
find: /home/lost+found: Permission denied
find: /lost+found: Permission denied
/etc/mysql/my.cnf
2) view the my.cnf file cat /etc/mysql/my.cnf
2)查看 my.cnf file cat /etc/mysql/my.cnf
yongmo@myserver:~$ cat /etc/mysql/my.cnf
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/english
skip-external-locking
3) Find the “datadir”
, this is where does MySQL stored the data in Linux system.
3)找到“datadir”
,这是MySQL在Linux系统中存储数据的地方。
回答by Victor P
In version 5.6 at least, the Management tab in MySQL Workbench shows that it's in a hidden folder called ProgramData in the C:\ drive. My default data directory is
至少在 5.6 版中,MySQL Workbench 中的 Management 选项卡显示它位于 C:\ 驱动器中名为 ProgramData 的隐藏文件夹中。我的默认数据目录是
C:\ProgramData\MySQL\MySQL Server 5.6\data
C:\ProgramData\MySQL\MySQL Server 5.6\data
. Each database has a folder and each table has a file here.
. 每个数据库都有一个文件夹,每个表都有一个文件。
回答by Skorunka Franti?ek
I just installed MySQL Server 5.7
on Windows 10
and my.ini
file is located here c:\ProgramData\MySQL\MySQL Server 5.7\my.ini
.
我刚装MySQL Server 5.7
上Windows 10
和my.ini
文件位于此处c:\ProgramData\MySQL\MySQL Server 5.7\my.ini
。
The Data
folder (where your dbs are created) is here C:/ProgramData/MySQL/MySQL Server 5.7\Data
.
该Data
文件夹(在其中创建您的DBS)是在这里C:/ProgramData/MySQL/MySQL Server 5.7\Data
。
回答by Gamage Pavithra Sankalpa
In mysql server 8.0, on Windows, the location is C:\ProgramData\MySQL\MySQL Server 8.0\Data
在 mysql server 8.0 中,在 Windows 上,位置是 C:\ProgramData\MySQL\MySQL Server 8.0\Data