MySQL配置文件(my.cnf)路径查看及相关配置

MySQL配置文件(my.cnf)路径查看及相关配置,第1张

查找my.cnf文件路径; 从上可以看出, 服务器首先会读取/etc/my.cnf文件,如果发现该文件不存在,再依次尝试从后面的几个路径进行读取。 参数详解:[client] #客户端设置,即客户端默认的连接参数 port = 3307 #默认连接端口 socket = /data/mysqldata/3307/mysql.sock #用于本地连接的socket套接字 default-character-set = utf8mb4 #编码 [mysqld] #服务端基本设置 port = 3307 MySQL监听端口 socket = /data/mysqldata/3307/mysql.sock #为MySQL客户端程序和服务器之间的本地通讯指定一个套接字文件 pid-file = /data/mysqldata/3307/mysql.pid#pid文件所在目录 basedir = /usr/local/mysql-5.7.11#使用该目录作为根目录(安装目录) datadir = /data/mysqldata/3307/data #数据文件存放的目录 tmpdir = /data/mysqldata/3307/tmp #MySQL存放临时文件的目录 character_set_server = utf8mb4 #服务端默认编码(数据库级别) collation_server = utf8mb4_bin #服务端默认的比对规则,排序规则 user = mysql #MySQL启动用户 log_bin_trust_function_creators = 1 #This variable applies when binary logging is enabled. It controls whether stored function creators can be trusted not to create stored functions that will cause #unsafe events to be written to the binary log. If set to 0 (the default), users are not permitted to create or alter stored functions unless they have the SUPER #privilege in addition to the CREATE ROUTINE or ALTER ROUTINE privilege. 开启了binlog后,必须设置这个值为1.主要是考虑binlog安全 performance_schema = 0 #性能优化的引擎,默认关闭 secure_auth = 1 #secure_auth 为了防止低版本的MySQL客户端(

一般linux 上都放在 /etc/my.cnf   ,window 上安装都是默认可能按照上面的路径还是没找到, window 上  可以登录到mysql中  使用   show variables like '%data%' 先找到data 存放路径, 一般my.ini 在 data文件的上一级。

win下的是my.ini,一般会在安装目录的根目录。

举例:

Windows7电脑上的方法。

1)从任务栏找到MySQL Notifier,右键单击,选择“SQL Editor”打开

2)可以看到MySQL Workbench被打开,从左侧边栏Navigator选择Options File;如果左侧没有Navigator,那么在右上角选择显示左侧边栏的选项。

3)在Workbench下部可以看到Configuration File所处的位置,即为my.ini的路径。

扩展资料:

使用 mysql --help 查看关于MYSQL对应 配置文件my.cnf 搜索顺序,windows 和linux 上都是该命令查看;  linux 上可以使用 mysql --help|grep my.cnf 过滤查看。

参考资料:mysql--MYSQL官网

[client]

port = 3306

socket = /tmp/mysql.sock

[mysqld]

##########################################################################################################

server-id = 1

port = 3306

user = mysql

##########################################################################################################

basedir = /usr/local/mysql-5.7.21

datadir = /usr/local/mysql-5.7.21/data

tmpdir = /tmp

socket = /tmp/mysql.sock

##########################################################################################################

transaction_isolation = REPEATABLE-READ

##########################################################################################################

default_storage_engine = InnoDB

default_tmp_storage_engine = InnoDB

internal_tmp_disk_storage_engine = InnoDB

character-set-server = utf8

collation-server = utf8_general_ci

lower_case_table_names = 1

##########################################################################################################

max_connections = 10000

max_connect_errors = 10000

open_files_limit = 65535

interactive_timeout = 1800

wait_timeout = 1800

back_log = 900

##########################################################################################################

max_allowed_packet = 128M

##########################################################################################################

tmp_table_size = 64M

max_heap_table_size = 64M

query_cache_type = 0

query_cache_size = 64M

query_cache_limit = 2M

query_cache_min_res_unit = 4kb

binlog_cache_size = 1M

key_buffer_size = 64M

read_buffer_size = 262144

read_rnd_buffer_size = 1M

sort_buffer_size = 1M

join_buffer_size = 1M

table_open_cache = 2000

table_definition_cache = 1400

table_open_cache_instances = 2

thread_cache_size = 16

thread_stack = 512k

##########################################################################################################

general_log = 0

general_log_file = /usr/local/mysql-5.7.21/log/mysql-general.log

log_error_verbosity = 2

log_error = /usr/local/mysql-5.7.21/log/mysql-error.log

slow_query_log = 1

long_query_time = 3

min_examined_row_limit = 100

log_throttle_queries_not_using_indexes = 0

slow_query_log_file = /usr/local/mysql-5.7.21/log/mysql-slow.log

log-queries-not-using-indexes = 1

log_bin = /usr/local/mysql-5.7.21/log/mysql-bin.log

expire_logs_days = 0

max_binlog_size = 1000M

binlog_format = row

##########################################################################################################

innodb_page_cleaners = 4

innodb_page_size = 16384

innodb_buffer_pool_size = 512M

innodb_buffer_pool_instances = 1

innodb_buffer_pool_chunk_size = 128M

innodb_buffer_pool_load_at_startup = 1

innodb_buffer_pool_dump_at_shutdown = 1

innodb_lru_scan_depth = 1024

innodb_lock_wait_timeout = 60

innodb_io_capacity = 2000

innodb_io_capacity_max = 4000

innodb_flush_method = O_DIRECT

innodb_file_per_table = 1

innodb_undo_directory = /usr/local/mysql-5.7.21/log

innodb_undo_tablespaces = 0

innodb_undo_logs = 128

innodb_undo_log_truncate = 1

innodb_max_undo_log_size = 1G

innodb_log_group_home_dir = /usr/local/mysql-5.7.21/log

innodb_log_file_size = 128M

innodb_log_files_in_group = 3

innodb_log_buffer_size = 16M

innodb_flush_log_at_timeout = 1

innodb_flush_log_at_trx_commit = 1

innodb_open_files = 8192

innodb_read_io_threads = 4

innodb_write_io_threads = 4

innodb_thread_concurrency = 0

innodb_purge_threads = 4

innodb_old_blocks_pct = 37

innodb_old_blocks_time=1000

innodb_use_native_aio = 1

innodb_data_home_dir=/usr/local/mysql-5.7.21/data

innodb_data_file_path = ibdata1:12M:autoextend

##########################################################################################################

explicit_defaults_for_timestamp = 1

[mysqldump]

quick

max_allowed_packet = 16M

[mysql]

auto-rehash

socket = /tmp/mysql.sock


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/7435496.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-05
下一篇 2023-04-05

发表评论

登录后才能评论

评论列表(0条)

保存