如何查看mysql的數據庫存放的路徑以及安裝路徑

2020年10月13日14:25:59 發表評論 62 views

如何查看mysql的數據庫存放的路徑以及安裝路徑

1.簡單查看路徑

1.查看數據庫的存放路徑

 

進入mysql終端
mysql>show variables like '%datadir%';

如何查看mysql的數據庫存放的路徑以及安裝路徑

2.查看文件安裝路徑

[root@hadoop01 etc]# whereis mysql
mysql: /usr/bin/mysql /usr/lib64/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

安裝了mysql,但是不知道文件都安裝在哪些地方、放在哪些文件夾里,可以用下面的命令查看所有的文件路徑? whereis

然后我們依次訪問上面四個文件夾和文件:

如何查看mysql的數據庫存放的路徑以及安裝路徑

如何查看mysql的數據庫存放的路徑以及安裝路徑
[root@hadoop01 ~]# cd /usr/bin/mysql
-bash: cd: /usr/bin/mysql: Not a directory
[root@hadoop01 ~]# more  /usr/bin/mysql
******** /usr/bin/mysql: Not a text file ********


[root@hadoop01 ~]# cd /usr/lib64/mysql
[root@hadoop01 mysql]# ll
total 9364
lrwxrwxrwx  1 root root      20 Oct  6 11:54 libmysqlclient_r.so.18 -> libmysqlclient.so.18
lrwxrwxrwx  1 root root      24 Oct  6 11:54 libmysqlclient_r.so.18.1.0 -> libmysqlclient.so.18.1.0
lrwxrwxrwx  1 root root      24 Oct  6 11:54 libmysqlclient.so.18 -> libmysqlclient.so.18.1.0
-rwxr-xr-x  1 root root 9581056 Sep 14  2017 libmysqlclient.so.18.1.0
drwxr-xr-x. 3 root root    4096 Oct  6 11:54 plugin


[root@hadoop01 mysql]# cd /usr/share/mysql
[root@hadoop01 mysql]# ll
total 1536
drwxr-xr-x  2 root root   4096 Oct  6 11:54 bulgarian
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 charsets
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 czech
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 danish
-rw-r--r--  1 root root  25575 Sep 13  2017 dictionary.txt
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 dutch
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 english
-rw-r--r--  1 root root 506007 Sep 13  2017 errmsg-utf8.txt
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 estonian
-rw-r--r--  1 root root 795692 Sep 13  2017 fill_help_tables.sql
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 french
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 german
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 greek
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 hungarian
-rw-r--r--  1 root root   3963 Sep 13  2017 innodb_memcached_config.sql
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 italian
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 japanese
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 korean
-rw-r--r--  1 root root    773 Sep 13  2017 magic
-rw-r--r--  1 root root   1126 Sep 14  2017 my-default.cnf
-rw-r--r--  1 root root    844 Sep 14  2017 mysql-log-rotate
-rw-r--r--  1 root root   1695 Sep 13  2017 mysql_security_commands.sql
-rw-r--r--  1 root root   3548 Sep 13  2017 mysql_system_tables_data.sql
-rw-r--r--  1 root root  93241 Sep 13  2017 mysql_system_tables.sql
-rw-r--r--  1 root root  10410 Sep 13  2017 mysql_test_data_timezone.sql
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 norwegian
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 norwegian-ny
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 polish
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 portuguese
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 romanian
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 russian
drwxr-xr-x  3 root root   4096 Oct  6 11:54 SELinux
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 serbian
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 slovak
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 spanish
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 swedish
drwxr-xr-x. 2 root root   4096 Oct  6 11:54 ukrainian

[root@hadoop01 ~]# cd /usr/share/man/man1/mysql.1.gz
-bash: cd: /usr/share/man/man1/mysql.1.gz: Not a directory
如何查看mysql的數據庫存放的路徑以及安裝路徑

 

3.詢運行文件所在路徑(文件夾地址)

只要查詢文件的運行文件所在地址,直接用下面的命令

如何查看mysql的數據庫存放的路徑以及安裝路徑

 

 

2.Linux下查看mysql是否安裝,以及安裝路徑。

如何查看mysql的數據庫存放的路徑以及安裝路徑
[root@hadoop01 mysql]#  ps -ef|grep mysql
mysql     1073     1  0 12:51 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
mysql     1336  1073  0 12:51 ?        00:00:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root      1589  1567  0 14:00 tty1     00:00:00 mysql -uroot -px xx
root      1632  1613  0 14:03 pts/0    00:00:00 mysql -uroot -px xx
root      1690  1635  0 14:21 pts/1    00:00:00 grep --color=auto mysql
如何查看mysql的數據庫存放的路徑以及安裝路徑
我們單獨拿出來講一下:

如何查看mysql的數據庫存放的路徑以及安裝路徑
/usr/sbin/mysqld 

--basedir=/usr 
#文件存放目錄
--datadir=/var/lib/mysql 
#mysql插件安裝地址
--plugin-dir=/usr/lib64/mysql/plugin
#錯誤日志 
--log-error=/var/log/mysqld.log 
#mysql進程id
--pid-file=/var/run/mysqld/mysqld.pid 
#文件是負責mysql的連接的,如果該文件不存在,則無法訪問mysql
--socket=/var/lib/mysql/mysql.sock
如何查看mysql的數據庫存放的路徑以及安裝路徑

那么做這些參數怎么來的?他是由/etc/my.conf 配置文件控制的

如何查看mysql的數據庫存放的路徑以及安裝路徑
/etc/my.cnf
[root@hadoop01 etc]# cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
如何查看mysql的數據庫存放的路徑以及安裝路徑

 

 

發表評論

您必須才能發表評論!