- 打卡等级:殷海萨
- 打卡总天数:765
- 打卡月天数:17
- 打卡总奖励:5193
|
楼主 |
发表于 2022-11-20 18:10:56
|
显示全部楼层
1,设置安装源vim /etc/yum.repo.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
2,确认源,安装mariadb
yum clean all
yum makecache
yum list --disablerepo=\* --enablerepo=mariadb
yum install MariaDB-client MariaDB-server MariaDB-devel -y
3,安装重启
systemctl start mariadb
systemctl enable mariadb
4,设置mysql
vim /etc/my.cnf
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
[client]
default_character_set=utf8mb4
[mysqld]
log-error=/var/lib/mysql/mysql.err
lower_case_table_names=1
character_set_server = utf8mb4
character_set_filesystem = utf8mb4
collation_server = utf8mb4_unicode_ci
character-set-client-handshake = FALSE
init_connect='SET NAMES utf8mb4'
#设置数据路径
datadir=/database/mysql
#设置端口
port=3307
#character_set_server=utf8
max_allowed_packet = 1280M
tmp_table_size= 640M
max_heap_table_size= 700M
event_scheduler=ON
#关闭mysql的dns反查功能
skip-name-resolve
innodb_force_recovery=0
##将mysqld 进程锁定在内存中
memlock
##查询缓存 (0 = off、1 = on、2 = demand)
query_cache_type=1
##连接繁忙阶段(query)起作用
net_read_timeout=3600
##连接繁忙阶段(query)起作用
net_write_timeout=3600
##通信缓冲大小
max_allowed_packet = 500M
##table高速缓存的数量
table_open_cache = 1024
##每个connection(session)第一次需要使用这个buffer的时候,一次性分配设置的内存
sort_buffer_size = 12M
##顺序读取数据缓冲区使用内存
read_buffer_size = 64M
sort_buffer_size = 32M
read_buffer_size = 32M
##随机读取数据缓冲区使用内存
read_rnd_buffer_size = 32M
thread_cache_size = 120
query_cache_size = 64M
#Join操作使用内存
join_buffer_size = 32M
##批量插入数据缓存大小
bulk_insert_buffer_size = 32M
##在表关闭之前,将对表的update操作指跟新数据到磁盘,而不更新索引到磁盘,把对索引的更改记录在内存。这样MyISAM表可以使索引更新更快。在关闭表的时候一起更新索引到磁盘
#delay_key_write=ON
#delayed_insert_limit=4000
#delayed_insert_timeout=600
#delayed_queue_size=4000
##CPU核数 * 2
thread_concurrency = 64
##最大连接(用户)数。每个连接MySQL的用户均算作一个连接
max_connections=20000
##最大失败连接限制
max_connect_errors=100000
##服务器关闭交互式连接前等待活动的秒数
interactive_timeout=2880000
##服务器关闭非交互连接之前等待活动的秒数
wait_timeout=2880000
##innodb_file_format=barracuda
##innodb_file_format_max=barracuda
#innodb_file_per_table=1
##innodb_fast_shutdown=0
transaction-isolation=READ-COMMITTED
##内存优化参数,一般设置为数据大小+10%
innodb_buffer_pool_size = 2048M
slow_query_log=2
#long_query_time=2
slow_query_log_file=db-slow.log
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
5,重启mysql,设置root的密码
mysql
alter user root@"%" identified by "123qqq"; 初始修改密码
6,授权用户
mysql> grant all on *.* to mydba@"%" identified by "123456" with grant option;
7,mysql数据备份
mysqldump -uroot -p'123qqq...A' -h 192.168.1.123 -P 3307 dc_customer > dc_customer.sql
8,mysql数据导入
mysql -uroot -p'123qqq...A' -h 192.168.1.122 -P 3307 dc_customer < dc_customer.sql
————————————————
|
|