mysql文件_mysql 文件位置 目录结构

0    查看mysql进程    ps -ef|grep mysql

[root@localhost mysql]# ps -ef|grep mysql

root10626 7899 0 09:14 pts/0 00:00:00 mysql -u zt_dev -p

root22002 10757 0 14:32 pts/1 00:00:00 grep --color=auto mysql

mysql28782 1 0 3月04 ? 00:00:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr

mysql28997 28782 3 3月04 ? 13:15:11 /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

查看文件安装路径 whereis mysql

[root@localhost mysql]# whereis mysql

mysql:/usr/bin/mysql /usr/lib64/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

查询运行文件所在路径 which mysql

[root@localhost mysql]# which mysql/usr/bin/mysql (运行文件是一堆乱码 看不懂 不要进去看了)

1   登录mysql后执行命令 show variables like '%dir%';

mysql> show variables like '%dir%';+-----------------------------------------+----------------------------+

| Variable_name | Value |

+-----------------------------------------+----------------------------+

| basedir | /usr/ |

| binlog_direct_non_transactional_updates | OFF |

| character_sets_dir | /usr/share/mysql/charsets/ |

| datadir | /var/lib/mysql/ |

| ignore_db_dirs | |

| innodb_data_home_dir | |

| innodb_log_group_home_dir | ./ |

| innodb_max_dirty_pages_pct | 75 |

| innodb_max_dirty_pages_pct_lwm | 0 |

| innodb_tmpdir | |

| innodb_undo_directory | . |

| lc_messages_dir | /usr/share/mysql/ |

| plugin_dir | /usr/lib64/mysql/plugin/ |

| slave_load_tmpdir | /tmp |

| tmpdir | /tmp |

+-----------------------------------------+----------------------------+

15 rows in set (0.00 sec)

2    数据库目录:/var/lib/mysql/

配置文件my.cnf中 会 有一条配置 datadir=/var/lib/mysql  指定数据库目录位置

linux 和 navicate 显示的数据库目录一样 如下

6bdaabab88859ba31e95e6510af0834a.png

3    配置文件  /etc/my.cnf

[root@localhost mysql]# 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]

character_set_server=utf8

collation-server=utf8_general_ci

#

# Remove leading # andset to the amount of RAM forthe most important data

# cachein 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 # toset options mainly useful forreporting servers.

# The server defaults are fasterfortransactions and fast SELECTs.

# Adjust sizesasneeded, experiment to find the optimal values.

# join_buffer_size=128M

# sort_buffer_size=2M

# read_rnd_buffer_size=2M

datadir=/var/lib/mysql mysql数据存储在这里

socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links isrecommended to prevent assorted security risks

symbolic-links=0# Recommendedinstandard 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

# Maximum lengthforGROUP_CONCAT

group_concat_max_len= -1

4    mysql.sock的作用

对mysql.sock来说,其作用是程序与mysqlserver处于同一台机器,发起本地连接时可用

例如你无须定义连接host的具体IP地址,只要为空或localhost就可以。

在此种情况下,即使你改变mysql的外部port也是一样可能正常连接。

因为你在my.ini中或my.cnf中改变端口后,mysql.sock是随每一次 mysql server启动生成的。已经根据你在更改完my.cnf后重启mysql时重新生成了一次,信息已跟着变更。

那么对于外部连接,必须是要变更port才能连接的。

linux下安装mysql连接的时候经常回提示说找不到mysql.sock文件,解决办法很简单:

如果是新安装的mysql,提示找不到文件,就搜索下,指定正确的位置。

如果mysql.sock文件误删的话,就需要重启mysql服务,如果重启成功的话会在datadir目录下面生成mysql.sock 到时候指定即可。

5    pid文件    /var/run/mysqld/mysqld.pid

当mysql实例启动时,会将自己的进程id写入一个文件中,

该文件即为pid文件。

6    错误日志log-error文件 /var/log/mysqld.log

[root@localhost mysql]# tail -f /var/log/mysqld.log

Version:'5.6.44' socket: '/var/lib/mysql/mysql.sock' port: 3306MySQL Community Server (GPL)2020-03-04 10:26:03 28997 [Warning] IP address 'xxx.xxx.x.xxx'could not be resolved: Name or service not known2020-03-04 10:26:45 28997 [Warning] IP address 'xxx.xxx.x.xx' could not be resolved: Name or service not known

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值