如何查看mysql的数据库存放的路径以及安装路径

网络评论阅读模式

如何查看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的数据库存放的路径以及安装路径

 

 

继续阅读
weinxin
我的微信
运营不易,
感谢支持!
网络最后更新:2020-10-22
公式库网
  • 本文由 发表于 2020年10月13日 14:25:59
  • 转载请务必保留本文链接:https://www.gongshiku.com/html/202010/ruhechakanmysqldeshujukucunfangdelujingyijianzhuanglujing.html
Python学习

Python操作pymysql详细示例

Python操作pymysql详细示例 程序在运行时,数据都是在内存中的。当程序终止时,通常需要将数据保存在磁盘上。前面我们有学过将数据写入文件就是保存到磁盘的一种方式。但是当面对大批量的数据时,为...
技巧

VMware虚拟机提速教程

虚拟机能在现有的系统上虚拟出多个独立的系统,尤其是开发人员测试人员经常会使用,但是大家经常对虚拟机的运行速度不甚满意,甚至经常很恼火。虚拟机速度慢有很多原因,需要根据自己的情况具体分析,本文根...

发表评论