简体   繁体   中英

Where/How are (My)SQL Databases Stored on Webservers?

Just curious as to where and how SQL databases are stored on web servers. My particular flavour of SQL is MySQL if it makes a difference, does it?

对于非平凡的网站,通常将SQL数据库,MySQL或其他方式存储在专用于DB服务器的单独服务器上。

For MySQL you can use SHOW VARIABLES to find out where the data lives on the file system:

mysql> show variables like "datadir";
+---------------+-----------------+
| Variable_name | Value           |
+---------------+-----------------+
| datadir       | /var/lib/mysql/ |
+---------------+-----------------+

Within that directory there will be one subdirectory for each database.

Within each database directory, you'll find the files used to store the table data and indexes. The precise structure of these depends on the storage engine used (typically MyISAM or InnoDB for MySQL).

It depends on the distro and the storage mechanism.

MyISAM databases are often stored in one file per table under /var/lib/mysql/[databasename]

All InnoDB databases are stored in the same file by default under, for example, /var/lib/mysql.

An optimized installation may have the database files live in a special filesystem optimized for speed or reliability, or both.

对于MySQL,数据存储在/ var / lib / mysql或类似的路径中,并且取决于您使用的数据库格式,对于MyISAM,数据库信息将存储在名称相同的目录中,其目录为.frm,.MYI和.MYD文件以及使用InnoDB的数据库信息将存储在ibdata1和ib_logfiles中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM