您的位置:首页 > 运维架构 > Linux

Centos6 通过RPM部署Mysql5.7

2017-08-15 11:17 411 查看
1.下载对应版本的mysql
rpm安装包

   本人用的是centos6.8 64位系统,mysql安装包官方下载地址 

2.安装mysql5.7

   安装步骤如下

   ①.查看系统已经安装过其他版本的mysql

     yum list installed | grep mysql  查看是否有安装过mysql  通过yum remove 卸载

    rpm -qa | grep -i mysql 查看是否有rpm包  通过rpm -e --nodeps移除
        
   ②. 安装依赖(Mysql5.7 需要安装)
        
yum -y install numactl


   ③.安装mysql rpm包
    
    
       只需要安装其中的四个
rpm -ivh  mysql-community-common-5.7.19-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.19-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.19-1.el6.x86_64.rpm
rpm -ivh  mysql-community-server-5.7.19-1.el6.x86_64.rpm


    
    

     ④.修改mysql配置文件my.cnf

     
       
[client]
default-character-set=utf8

[mysqld]
character_set_server=utf8
    

     ⑤.启动mysql并查看mysql初始化的随机密码

        service mysqld start

        grep 'temporary password' /var/log/mysqld.log

      



      ⑥.修改初始密码

        ALTER USER 'root'@'localhost' IDENTIFIED BY 'new
password'; 

        

   需要注意是的 5.7中 设置的密码安全度有点高,需要有大小写字母数字特殊字符,可以更改后,再去my.cnf中加入validate_password=OFF 去除密码安全度验证。

    

   最后附上 自用的生产环境Mysql配置(部分配置用于主从同步可以忽略,具体参数根据服务器配置设置)

[client]

port= 3306

socket= /tmp/mysql.sock

[mysqld]

basedir=/usr

datadir=/data/mysql

port=3306

socket=/tmp/mysql.sock

character-set-server = utf8mb4

default-storage-engine  = InnoDB

symbolic-links=0

skip-name-resolve = 1

open_files_limit = 65535

back_log = 384

max_connections = 5000

max_connect_errors = 100000

table_open_cache = 2048

tmp-table-size   = 32M

max-heap-table-size = 32M

#query-cache-type  = 0

query-cache-size  = 0

external-locking = FALSE

max_allowed_packet = 32M

sort_buffer_size = 2M

join_buffer_size = 2M

thread_cache_size = 51

query_cache_size = 32M

tmp_table_size = 512M

max_heap_table_size = 96M

query_cache_type=1

log-error=/data/logs/mysqld.log

slow_query_log = 1

slow_query_log_file = /data/logs/slow.log

long_query_time = 0.1

# BINARY LOGGING #

server-id = 1

log-bin          = /data/binlog/mysql-bin

log-bin-index    =/data/binlog/mysql-bin.index

expire-logs-days = 14

sync_binlog = 1

binlog_cache_size = 2048M

max_binlog_cache_size = 4096M

max_binlog_size = 1024M

log_slave_updates

#binlog_format = row 

binlog_format = MIXED 

relay_log_recovery = 1

pid-file=/data/mysql/mysqld.pid

#不需要同步的表

#replicate-wild-ignore-table=mydb.sp_counter

#不需要同步的库

replicate-ignore-db = mysql,information_schema,performance_schema,sys

key_buffer_size = 768M

read_buffer_size = 1M

read_rnd_buffer_size = 16M

bulk_insert_buffer_size = 64M

myisam_sort_buffer_size = 128M

myisam_max_sort_file_size = 10G

myisam_repair_threads = 1

myisam_recover_options=force,backup

transaction_isolation = REPEATABLE-READ

#innodb_additional_mem_pool_size = 16M

innodb_buffer_pool_size = 18G

innodb_buffer_pool_load_at_startup = 1

innodb_buffer_pool_dump_at_shutdown = 1

innodb_data_file_path = ibdata1:1024M:autoextend

innodb_flush_log_at_trx_commit = 2

innodb_log_buffer_size = 128M

innodb_log_file_size = 2G

innodb_log_files_in_group = 2

innodb_io_capacity = 4000

innodb_io_capacity_max = 8000

innodb_max_dirty_pages_pct = 50

innodb_flush_method = O_DIRECT

innodb_file_format = Barracuda

innodb_file_format_max = Barracuda

innodb_lock_wait_timeout = 10

innodb_rollback_on_timeout = 1

innodb_print_all_deadlocks = 1

innodb_file_per_table = 1

innodb_locks_unsafe_for_binlog = 0

lower_case_table_names=1

validate_password=OFF

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

## Thread settings

#thread_concurrency=24

#thread_cache_size=250

[mysqldump]

quick

max_allowed_packet = 128M
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  centos mysql