广元市楚河网络科技有限公司
首页 | 联系方式 | 加入收藏 | 设为首页 | 手机站

产品目录

联系方式

联系人:业务部
电话: 00164-826657
邮箱:service@tanaosot.com

当前位置:首页 >> 产品展示 >> 默认分类 >> 正文

MySQL 配置文件

详细信息:

编辑配置文件
vim /etc/my.cnf

[client]
port = 3306
socket = /usr/local/mysql/mysql.sock
default-character-set = utf8mb4

[mysqld]
port = 3306
basedir = /usr/local/mysql/
datadir=/usr/local/mysql/data # mysql数据存储目录
socket= /usr/local/mysql/mysql.sock
pid-file = /usr/local/mysql/mysql.pid
user = mysql
secure_file_priv=/usr/local/mysql/mysql-files #设置导入导出文件目录
local_infile=1 #为了避免加载数据的本地版本可能出现的安全问题,请确保默认启用local_infile
bind-address = 0.0.0.0
server-id = 1
init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4
#skip-name-resolve
#skip-networking
back_log = 300
max_connections = 200 # 支持的最大并发链接数,这个根据实际业务需求去设置
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size = 10 # 缓存的最大线程数,本机内存2G 设置15个左右即可
query_cache_type = 1
query_cache_size = 10M #指定MySQL查询缓冲区的大小,本机内存为2G 设置100M左右即可
query_cache_limit = 2M
ft_min_word_len = 4
log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 30 #超过30天的binlog删除
log_error = /usr/local/mysql/bin-logs/mysql-error.log
slow_query_log = 1
long_query_time = 1 #慢查询时间 超过1秒则为慢查询
slow_query_log_file = /usr/local/mysql/bin-logs/slow.log #查询日志文件
performance_schema = 0
explicit_defaults_for_timestamp
lower_case_table_names = 1 #不区分大小写
skip-external-locking
default_storage_engine = InnoDB
#default-storage-engine = MyISAM
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
interactive_timeout = 28800
wait_timeout = 300 #(秒)指定一个请求的最大连接时间,默认为28800 (八小时)

[mysqldump]
quick
max_allowed_packet = 16M

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M

==============================================

初始化mysql
cd /usr/local/mysql/bin
./mysqld \
--defaults-file=/etc/my.cnf \
--initialize \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data

grep password /usr/local/mysql/log/mysqld.log

修改密码

alter user 'root'@'localhost' identified by 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root1'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION; #授权新用户

flush privileges;

============================

CMAKE

#安装目录
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
#数据库存放目录
-DMYSQL_DATADIR=/usr/local/mysql/data
#系统配置目录
-DSYSCONFDIR=/etc
#Unix socket 文件路径
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock
#安装 myisam 存储引擎
-DWITH_MYISAM_STORAGE_ENGINE=1
#安装 innodb 存储引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1
#安装 archive 存储引擎
-DWITH_ARCHIVE_STORAGE_ENGINE=1
#安装 blackhole 存储引擎
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
#安装数据库分区
-DWITH_PARTITION_STORAGE_ENGINE=1
#允许从本地导入数据
-DENABLED_LOCAL_INFILE=1
#快捷键功能
-DWITH_READLINE=1
#支持 SSL
-DWITH_SSL=yes
#使用 utf8mb4 字符
-DDEFAULT_CHARSET=utf8mb4 \
#校验字符
-DDEFAULT_COLLATION=utf8mb4_general_ci
#安装所有扩展字符集
-DEXTRA_CHARSETS=all
#MySQL 监听端口
-DMYSQL_TCP_PORT=3306
#带boost安装包安装
-DWITH_BOOST=boost
#不带boost
-DWITH_BOOST=boost \
-DWITH_BOOST=/usr/local/boost \