mysql之centos安装

1、配置及说明

  • OS:CentOS Linux release 7.6.1810 (Core)
  • msyql:mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz

链接:https://pan.baidu.com/s/10jXeVKZ1BVntu-doyx-GoA   提取码:foaj 

2、安装步骤

 

mkdir /data/mysql

2.1、文件上传并解压

tar -zxvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
mv /mysql-5.7.25-linux-glibc2.12-x86_64/  /usr/local/mysql

2.2、创建mysql用户组及用户

groupadd mysql
useradd -r -g mysql mysql

2.3、关联mysql用户到mysql用户组中

cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .

chown -R mysql /data/mysql

2.4、安装libaio

yum search libaio
yum install libaio

2.5、初始化mysql

cd /usr/local/mysql/bin
./mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql --initialize

PS:注意初始化时临时账号与密码

2.6、修改mysql配置文件

vim /mysql/support-files/mysql.server
basedir=/usr/local/mysql#原basedir=
datadir=/data/mysql#原datadir=
cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld
chown -R mysql /etc/init.d/mysqld

2.7、mysql配置优化

vi /etc/my.cnf
# Generated by Percona Configuration Wizard (http://tools.percona.com/) version REL5-20120208
# Configuration name SY-CZ-Server-88  generated for [email protected] at 2018-10-19 13:31:28

[mysql]

# CLIENT #
port                           = 3306
socket                         = /usr/local/mysql/mysql.sock

[mysqld]

# GENERAL #
user                           = mysql
default-storage-engine         = InnoDB
socket                         = /usr/local/mysql/mysql.sock
pid-file                       = /usr/local/mysql/mysqld.pid
default-time_zone = '+8:00'
gtid_mode=ON
enforce_gtid_consistency=ON
character-set-server=utf8
collation-server=utf8_general_ci
slave-parallel-type=LOGICAL_CLOCK
slave-parallel-workers=16
master_info_repository=TABLE
relay_log_info_repository=TABLE
relay_log_recovery=ON
log_bin_trust_function_creators=1
thread_cache_size=300
back_log=1024
# MyISAM #
key-buffer-size                = 32M
myisam-recover-options         = FORCE,BACKUP

# SAFETY #
max-allowed-packet             = 16M
max-connect-errors             = 1000000
sql-mode                       = STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_AUTO_VALUE_ON_ZERO
innodb                         = FORCE

# DATA STORAGE #
datadir                        = /data/mysql

# BINARY LOGGING #
log-bin                        = /data/mysql/mysql-bin
expire-logs-days               = 14
sync-binlog                    = 1
server-id=138
# CACHES AND LIMITS #
tmp-table-size                 = 32M
max-heap-table-size            = 32M
sort_buffer_size = 4M
query-cache-type               = 0
query-cache-size               = 0
max-connections                = 1024
thread-cache-size              = 100
open-files-limit               = 65535
table-definition-cache         = 4096
table-open-cache               = 2048

# INNODB #
innodb-flush-method            = O_DIRECT
innodb-log-files-in-group      = 2
innodb-log-file-size           = 1G
innodb_log_buffer_size         = 64M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table          = 1
innodb-buffer-pool-size        = 96G
innodb_buffer_pool_chunk_size  = 256M
innodb_io_capacity = 50000
innodb_io_capacity_max = 80000
innodb_flush_neighbors = 0
innodb_write_io_threads = 16
innodb_read_io_threads = 16
innodb_open_files = 65535
innodb_max_dirty_pages_pct = 50
innodb_print_all_deadlocks = 1
innodb_sort_buffer_size = 16M 
# LOGGING #
log-error                      = /usr/local/mysql/log/mysql-error.log
log-queries-not-using-indexes  = 1
slow-query-log                 = 1
slow-query-log-file            = /usr/local/mysql/log/mysql-slow.log
log_queries_not_using_indexes = 1
[mysqldump]
quick
max_allowed_packet = 32M

PS:新建mysql-error.log、mysql-slow.log文件

2.8、启动mysql

/etc/init.d/mysql start

mysql -hlocalhost -uroot -p
#若出现command not found,执行ln -s /usr/local/mysql/bin/mysql /usr/bin,然后输入临时密码
set password=password('12345');

grant all privileges on *.* to 'root'@'%' identified by '12345';

flush privileges;

 

你可能感兴趣的:(学习笔记)