提示文章写完后目录可以自动生成如何生成可参考右边的帮助文档文章目录一、MySQL 的数据目录1、数据库文件的存放路径2、相关命令目录3、配置文件目录二、数据库和文件系统的关系1、查看默认数据库2、数据库在文件系统中的表示3、表在文件系统中的表示1、InnoDB 存储引擎模式2、MyISAM 存储引擎模式4、视图在文件系统中的表示5、其他的文件一、MySQL 的数据目录查看目录结构[rootlocalhost ~]# find / -name mysql /etc/logrotate.d/mysql /etc/selinux/targeted/active/modules/100/mysql /var/lib/mysql /var/lib/mysql/mysql /usr/bin/mysql /usr/lib64/mysql [rootlocalhost ~]#1、数据库文件的存放路径mysql show variables like datadir; -------------------------------- | Variable_name | Value | -------------------------------- | datadir | /var/lib/mysql/ | -------------------------------- 1 row in set (0.01 sec)2、相关命令目录3、配置文件目录[rootlocalhost ~]# cd /usr/share/mysql-8.0 [rootlocalhost mysql-8.0]# ll 总用量 992 drwxr-xr-x. 2 root root 24 12月 2 15:08 bulgarian drwxr-xr-x. 2 root root 4096 12月 2 15:08 charsets drwxr-xr-x. 2 root root 24 12月 2 15:08 czech drwxr-xr-x. 2 root root 24 12月 2 15:08 danish -rw-r--r--. 1 root root 25575 7月 1 2021 dictionary.txt drwxr-xr-x. 2 root root 24 12月 2 15:08 dutch drwxr-xr-x. 2 root root 24 12月 2 15:08 english drwxr-xr-x. 2 root root 24 12月 2 15:08 estonian drwxr-xr-x. 2 root root 24 12月 2 15:08 french drwxr-xr-x. 2 root root 24 12月 2 15:08 german drwxr-xr-x. 2 root root 24 12月 2 15:08 greek drwxr-xr-x. 2 root root 24 12月 2 15:08 hungarian -rw-r--r--. 1 root root 3999 7月 1 2021 innodb_memcached_config.sql -rw-r--r--. 1 root root 2216 7月 1 2021 install_rewriter.sql drwxr-xr-x. 2 root root 24 12月 2 15:08 italian drwxr-xr-x. 2 root root 24 12月 2 15:08 japanese drwxr-xr-x. 2 root root 24 12月 2 15:08 korean -rw-r--r--. 1 root root 610894 7月 1 2021 messages_to_clients.txt -rw-r--r--. 1 root root 348904 7月 1 2021 messages_to_error_log.txt -rw-r--r--. 1 root root 1977 7月 1 2021 mysql-log-rotate drwxr-xr-x. 2 root root 24 12月 2 15:08 norwegian drwxr-xr-x. 2 root root 24 12月 2 15:08 norwegian-ny drwxr-xr-x. 2 root root 24 12月 2 15:08 polish drwxr-xr-x. 2 root root 24 12月 2 15:08 portuguese drwxr-xr-x. 2 root root 24 12月 2 15:08 romanian drwxr-xr-x. 2 root root 24 12月 2 15:08 russian drwxr-xr-x. 2 root root 24 12月 2 15:08 serbian drwxr-xr-x. 2 root root 24 12月 2 15:08 slovak drwxr-xr-x. 2 root root 24 12月 2 15:08 spanish drwxr-xr-x. 2 root root 24 12月 2 15:08 swedish drwxr-xr-x. 2 root root 24 12月 2 15:08 ukrainian -rw-r--r--. 1 root root 1248 7月 1 2021 uninstall_rewriter.sql [rootlocalhost mysql-8.0]# [rootlocalhost mysql-8.0]# cd /etc [rootlocalhost etc]# ll 总用量 1092 drwxr-xr-x. 3 root root 101 10月 21 11:52 abrt -rw-r--r--. 1 root root 16 10月 21 11:56 adjtime -rw-r--r--. 1 root root 1518 6月 7 2013 aliases -rw-r--r--. 1 root root 12288 10月 21 15:26 aliases.db drwxr-xr-x. 2 root root 44 11月 29 16:10 alternatives -rw-------. 1 root root 541 8月 3 2017 anacrontab -rw-r--r--. 1 root root 55 3月 1 2017 asound.conf drwxr-x---. 3 root root 43 10月 21 11:53 audisp drwxr-x---. 3 root root 83 10月 21 15:26 audit drwxr-xr-x. 2 root root 68 10月 21 11:53 bash_completion.d -rw-r--r--. 1 root root 2853 11月 6 2016 bashrc drwxr-xr-x. 2 root root 6 8月 5 2017 binfmt.d -rw-r--r--. 1 root root 38 8月 30 2017 centos-release -rw-r--r--. 1 root root 51 8月 30 2017 centos-release-upstream drwxr-xr-x. 2 root root 6 8月 4 2017 chkconfig.d -rw-r--r--. 1 root root 1108 1月 31 2017 chrony.conf -rw-r-----. 1 root chrony 481 1月 31 2017 chrony.keys drwxr-xr-x. 2 root root 21 10月 21 11:52 cron.d drwxr-xr-x. 2 root root 42 10月 21 11:53 cron.daily -rw-------. 1 root root 0 8月 3 2017 cron.deny drwxr-xr-x. 2 root root 22 6月 10 2014 cron.hourly drwxr-xr-x. 2 root root 6 6月 10 2014 cron.monthly -rw-r--r--. 1 root root 451 6月 10 2014 crontab drwxr-xr-x. 2 root root 6 6月 10 2014 cron.weekly -rw-------. 1 root root 0 10月 21 11:50 crypttab -rw-r--r--. 1 root root 1620 11月 6 2016 csh.cshrc -rw-r--r--. 1 root root 841 6月 7 2013 csh.login drwxr-xr-x. 4 root root 78 10月 21 11:52 dbus-1 drwxr-xr-x. 2 root root 44 10月 21 11:56 default drwxr-xr-x. 2 root root 23 10月 21 11:52 depmod.d drwxr-x---. 4 root root 53 10月 21 11:52 dhcp -rw-r--r--. 1 root root 5090 11月 5 2016 DIR_COLORS -rw-r--r--. 1 root root 5725 11月 5 2016 DIR_COLORS.256color -rw-r--r--. 1 root root 4669 11月 5 2016 DIR_COLORS.lightbgcolor -rw-r--r--. 1 root root 1285 8月 5 2017 dracut.conf drwxr-xr-x. 2 root root 6 8月 5 2017 dracut.conf.d -rw-r--r--. 1 root root 112 3月 16 2017 e2fsck.conf drwxr-xr-x. 3 root root 37 11月 6 16:06 egl -rw-r--r--. 1 root root 0 11月 6 2016 environment -rw-r--r--. 1 root root 1317 11月 6 2016 ethertypes -rw-r--r--. 1 root root 0 6月 7 2013 exports lrwxrwxrwx. 1 root root 56 10月 21 11:52 favicon.png - /usr/share/icons/hicolor/16x16/apps/fedora-logo-icon.png -rw-r--r--. 1 root root 70 11月 6 2016 filesystems drwxr-x---. 7 root root 133 10月 21 11:53 firewalld drwxr-xr-x. 3 root root 38 11月 6 16:05 fonts -rw-r--r--. 1 root root 465 10月 21 11:50 fstab -rw-r--r--. 1 root root 38 5月 2 2017 fuse.conf drwxr-xr-x. 2 root root 6 8月 2 2017 gcrypt -rw-r--r--. 1 root root 265 6月 14 2017 gdbinit drwxr-xr-x. 2 root root 6 6月 14 2017 gdbinit.d -rw-r--r--. 1 root root 842 11月 6 2016 GeoIP.conf -rw-r--r--. 1 root root 858 11月 6 2016 GeoIP.conf.default drwxr-xr-x. 3 root root 26 11月 6 16:06 glvnd drwxr-xr-x. 2 root root 6 11月 6 2016 gnupg -rw-r--r--. 1 root root 94 3月 25 2017 GREP_COLORS drwxr-xr-x. 4 root root 40 10月 21 11:51 groff -rw-r--r--. 1 root root 545 12月 2 15:09 group -rw-r--r--. 1 root root 533 10月 23 17:55 group- lrwxrwxrwx. 1 root root 22 10月 21 11:52 grub2.cfg - ../boot/grub2/grub.cfg drwx------. 2 root root 182 10月 21 11:55 grub.d ----------. 1 root root 432 12月 2 15:09 gshadow ----------. 1 root root 422 10月 23 17:55 gshadow- drwxr-xr-x. 3 root root 20 10月 21 11:51 gss -rw-r--r--. 1 root root 9 6月 7 2013 host.conf -rw-r--r--. 1 root root 22 10月 21 11:56 hostname -rw-r--r--. 1 root root 158 6月 7 2013 hosts -rw-r--r--. 1 root root 370 6月 7 2013 hosts.allow -rw-r--r--. 1 root root 460 6月 7 2013 hosts.deny lrwxrwxrwx. 1 root root 11 10月 21 11:51 init.d - rc.d/init.d -rw-r--r--. 1 root root 511 8月 4 2017 inittab -rw-r--r--. 1 root root 942 6月 7 2013 inputrc drwxr-xr-x. 2 root root 140 10月 21 11:51 iproute2 -rw-r--r--. 1 root root 23 8月 30 2017 issue -rw-r--r--. 1 root root 22 8月 30 2017 issue.net -rw-r--r--. 1 root root 7265 10月 21 11:52 kdump.conf drwxr-xr-x. 2 root root 37 11月 29 16:10 keepalived drwxr-xr-x. 3 root root 24 10月 21 11:53 kernel -rw-r--r--. 1 root root 590 4月 29 2017 krb5.conf drwxr-xr-x. 2 root root 6 8月 4 2017 krb5.conf.d drwxr-xr-x. 3 root root 41 10月 21 11:53 latrace.d -rw-r--r--. 1 root root 35292 12月 2 15:08 ld.so.cache -rw-r--r--. 1 root root 28 2月 28 2013 ld.so.conf drwxr-xr-x. 2 root root 99 12月 2 15:08 ld.so.conf.d -rw-r-----. 1 root root 191 4月 19 2017 libaudit.conf drwxr-xr-x. 2 root root 35 10月 21 11:51 libnl drwxr-xr-x. 6 root root 149 10月 21 11:52 libreport -rw-r--r--. 1 root root 2391 10月 13 2013 libuser.conf -rw-r--r--. 1 root root 19 10月 21 11:56 locale.conf lrwxrwxrwx. 1 root root 35 10月 21 11:56 localtime - ../usr/share/zoneinfo/Asia/Shanghai -rw-r--r--. 1 root root 2028 11月 5 2016 login.defs -rw-r--r--. 1 root root 662 7月 31 2013 logrotate.conf drwxr-xr-x. 2 root root 95 12月 2 15:09 logrotate.d drwxr-xr-x. 6 root root 100 10月 21 11:53 lvm -r--r--r--. 1 root root 33 10月 21 11:52 machine-id -rw-r--r--. 1 root root 111 11月 6 2016 magic -rw-r--r--. 1 root root 1968 8月 3 2017 mail.rc -rw-r--r--. 1 root root 5122 8月 7 2017 makedumpfile.conf.sample -rw-r--r--. 1 root root 5171 6月 10 2014 man_db.conf -rw-r--r--. 1 root root 936 8月 3 2017 mke2fs.conf drwxr-xr-x. 2 root root 24 10月 21 11:53 modprobe.d drwxr-xr-x. 2 root root 6 8月 5 2017 modules-load.d -rw-r--r--. 1 root root 0 6月 7 2013 motd lrwxrwxrwx. 1 root root 17 10月 21 11:50 mtab - /proc/self/mounts -rw-r--r--. 1 root root 1243 7月 1 2021 my.cnf drwxr-xr-x. 2 root root 6 7月 1 2021 my.cnf.d drwxr-xr-x. 7 root root 134 8月 4 2017 NetworkManager -rw-r--r--. 1 root root 58 8月 4 2017 networks -rw-r--r--. 1 root root 1746 10月 21 11:52 nsswitch.conf -rw-r--r--. 1 root root 1735 8月 2 2017 nsswitch.conf.bak drwxr-xr-x. 3 root root 36 10月 21 11:52 openldap drwxr-xr-x. 2 root root 6 11月 5 2016 opt -rw-r--r--. 1 root root 393 8月 30 2017 os-release drwxr-xr-x. 2 root root 4096 11月 29 16:10 pam.d -rw-r--r--. 1 root root 1086 12月 2 15:09 passwd -rw-r--r--. 1 root root 1033 10月 23 17:55 passwd- drwxr-xr-x. 3 root root 21 10月 21 11:51 pkcs11 drwxr-xr-x. 10 root root 116 10月 21 11:53 pki drwxr-xr-x. 2 root root 28 10月 21 11:52 plymouth drwxr-xr-x. 5 root root 52 10月 21 11:50 pm drwxr-xr-x. 5 root root 72 10月 21 11:52 polkit-1 drwxr-xr-x. 2 root root 6 6月 10 2014 popt.d drwxr-xr-x. 3 root root 123 10月 21 11:52 ppp drwxr-xr-x. 2 root root 78 10月 21 11:52 prelink.conf.d -rw-r--r--. 1 root root 233 6月 7 2013 printcap -rw-r--r--. 1 root root 1849 11月 6 16:58 profile drwxr-xr-x. 2 root root 247 11月 4 16:19 profile.d -rw-r--r--. 1 root root 6545 6月 7 2013 protocols drwxr-xr-x. 2 root root 35 10月 21 11:51 python lrwxrwxrwx. 1 root root 10 10月 21 11:51 rc0.d - rc.d/rc0.d lrwxrwxrwx. 1 root root 10 10月 21 11:51 rc1.d - rc.d/rc1.d lrwxrwxrwx. 1 root root 10 10月 21 11:51 rc2.d - rc.d/rc2.d lrwxrwxrwx. 1 root root 10 10月 21 11:51 rc3.d - rc.d/rc3.d lrwxrwxrwx. 1 root root 10 10月 21 11:51 rc4.d - rc.d/rc4.d lrwxrwxrwx. 1 root root 10 10月 21 11:51 rc5.d - rc.d/rc5.d lrwxrwxrwx. 1 root root 10 10月 21 11:51 rc6.d - rc.d/rc6.d drwxr-xr-x. 10 root root 127 10月 21 11:52 rc.d lrwxrwxrwx. 1 root root 13 10月 21 11:52 rc.local - rc.d/rc.local lrwxrwxrwx. 1 root root 14 10月 21 11:50 redhat-release - centos-release -rw-r--r--. 1 root root 76 12月 3 14:10 resolv.conf -rw-r--r--. 1 root root 1634 12月 25 2012 rpc drwxr-xr-x. 2 root root 208 11月 6 16:44 rpm -rw-r--r--. 1 root root 458 8月 2 2017 rsyncd.conf -rw-r--r--. 1 root root 3232 5月 10 2017 rsyslog.conf drwxr-xr-x. 2 root root 25 8月 7 2017 rsyslog.d -rw-r--r--. 1 root root 966 8月 4 2017 rwtab drwxr-xr-x. 2 root root 23 8月 4 2017 rwtab.d drwxr-xr-x. 2 root root 6 11月 29 16:10 sasl2 -rw-------. 1 root root 221 11月 6 2016 securetty drwxr-xr-x. 6 root root 4096 10月 21 11:52 security drwxr-xr-x. 5 root root 81 10月 21 11:52 selinux -rw-r--r--. 1 root root 670293 6月 7 2013 services -rw-r--r--. 1 root root 216 8月 4 2017 sestatus.conf drwxr-xr-x. 3 root root 21 10月 21 11:51 sgml ----------. 1 root root 772 12月 2 15:09 shadow ----------. 1 root root 751 10月 23 17:58 shadow- -rw-r--r--. 1 root root 76 6月 7 2013 shells drwxr-xr-x. 2 root root 62 10月 21 11:51 skel -rw-r--r--. 1 root root 100 8月 10 2017 sos.conf drwxr-xr-x. 2 root root 225 10月 21 15:26 ssh drwxr-xr-x. 2 root root 19 10月 21 11:51 ssl -rw-r--r--. 1 root root 212 8月 4 2017 statetab drwxr-xr-x. 2 root root 6 8月 4 2017 statetab.d -rw-r--r--. 1 root root 0 11月 6 2016 subgid -rw-r--r--. 1 root root 0 11月 6 2016 subuid drwxr-xr-x. 2 root root 6 11月 21 2015 subversion -rw-r-----. 1 root root 1786 6月 7 2017 sudo.conf -r--r-----. 1 root root 3938 6月 7 2017 sudoers drwxr-x---. 2 root root 6 8月 4 2017 sudoers.d -rw-r-----. 1 root root 3181 6月 7 2017 sudo-ldap.conf drwxr-xr-x. 6 root root 4096 11月 29 16:10 sysconfig -rw-r--r--. 1 root root 449 8月 4 2017 sysctl.conf drwxr-xr-x. 2 root root 28 10月 21 11:52 sysctl.d drwxr-xr-x. 4 root root 151 10月 21 11:52 systemd lrwxrwxrwx. 1 root root 14 10月 21 11:50 system-release - centos-release -rw-r--r--. 1 root root 23 8月 30 2017 system-release-cpe -rw-------. 1 tss tss 7046 8月 4 2017 tcsd.conf drwxr-xr-x. 2 root root 6 6月 11 2014 terminfo drwxr-xr-x. 2 root root 6 8月 5 2017 tmpfiles.d drwxr-xr-x. 2 root root 70 10月 21 11:53 tuned drwxr-xr-x. 3 root root 54 10月 21 15:26 udev -rw-r--r--. 1 root root 37 10月 21 11:56 vconsole.conf -rw-r--r--. 1 root root 1982 12月 16 2020 vimrc -rw-r--r--. 1 root root 1982 8月 2 2017 virc drwxr-xr-x. 5 root root 231 10月 21 11:53 vmware-tools -rw-r--r--. 1 root root 4479 5月 16 2019 wgetrc drwxr-xr-x. 2 root root 33 10月 21 11:52 wpa_supplicant drwxr-xr-x. 5 root root 57 10月 21 11:52 X11 drwxr-xr-x. 4 root root 38 10月 21 11:52 xdg drwxr-xr-x. 2 root root 6 11月 5 2016 xinetd.d drwxr-xr-x. 2 root root 21 10月 21 11:51 xml drwxr-xr-x. 6 root root 100 10月 21 11:52 yum -rw-r--r--. 1 root root 970 8月 6 2017 yum.conf drwxr-xr-x. 2 root root 27 10月 30 17:39 yum.repos.d [rootlocalhost etc]#二、数据库和文件系统的关系1、查看默认数据库mysql SHOW DATABASES; -------------------- | Database | -------------------- | dbtest1 | | information_schema | | mysql | | performance_schema | | sys | -------------------- 5 rows in set (0.00 sec)2、数据库在文件系统中的表示[rootlocalhost ~]# cd /var/lib/mysql [rootlocalhost mysql]# ll 总用量 188872 -rw-r-----. 1 mysql mysql 56 12月 2 15:16 auto.cnf -rw-r-----. 1 mysql mysql 2720 12月 3 14:11 binlog.000001 -rw-r-----. 1 mysql mysql 156 12月 3 14:11 binlog.000002 -rw-r-----. 1 mysql mysql 32 12月 3 14:11 binlog.index -rw-------. 1 mysql mysql 1676 12月 2 15:16 ca-key.pem -rw-r--r--. 1 mysql mysql 1112 12月 2 15:16 ca.pem -rw-r--r--. 1 mysql mysql 1112 12月 2 15:16 client-cert.pem -rw-------. 1 mysql mysql 1676 12月 2 15:16 client-key.pem drwxr-x---. 2 mysql mysql 22 12月 2 17:51 dbtest1 -rw-r-----. 1 mysql mysql 196608 12月 3 14:13 #ib_16384_0.dblwr -rw-r-----. 1 mysql mysql 8585216 12月 2 15:16 #ib_16384_1.dblwr -rw-r-----. 1 mysql mysql 5887 12月 2 15:16 ib_buffer_pool -rw-r-----. 1 mysql mysql 12582912 12月 3 14:11 ibdata1 -rw-r-----. 1 mysql mysql 50331648 12月 3 14:13 ib_logfile0 -rw-r-----. 1 mysql mysql 50331648 12月 2 15:16 ib_logfile1 -rw-r-----. 1 mysql mysql 12582912 12月 3 14:11 ibtmp1 drwxr-x---. 2 mysql mysql 187 12月 3 14:11 #innodb_temp drwxr-x---. 2 mysql mysql 143 12月 2 15:16 mysql -rw-r-----. 1 mysql mysql 25165824 12月 3 14:11 mysql.ibd srwxrwxrwx. 1 mysql mysql 0 12月 3 14:11 mysql.sock -rw-------. 1 mysql mysql 5 12月 3 14:11 mysql.sock.lock drwxr-x---. 2 mysql mysql 8192 12月 2 15:16 performance_schema -rw-------. 1 mysql mysql 1680 12月 2 15:16 private_key.pem -rw-r--r--. 1 mysql mysql 452 12月 2 15:16 public_key.pem -rw-r--r--. 1 mysql mysql 1112 12月 2 15:16 server-cert.pem -rw-------. 1 mysql mysql 1680 12月 2 15:16 server-key.pem drwxr-x---. 2 mysql mysql 28 12月 2 15:16 sys -rw-r-----. 1 mysql mysql 16777216 12月 3 14:13 undo_001 -rw-r-----. 1 mysql mysql 16777216 12月 3 14:13 undo_0023、表在文件系统中的表示1、InnoDB 存储引擎模式2、MyISAM 存储引擎模式小结4、视图在文件系统中的表示5、其他的文件