Centos7下Mysql5.7.14的二进制安装

  • 内容
  • 评论
  • 相关

参考文档:http://dev.mysql.com/doc/refman/5.7/en/binary-installation.html

创建相关用户

groupadd mysql

useradd -r -g mysql mysql

创建安装目录

mkdir -p /home/apps

安装依赖库及下载文件

yum -y install libaio

wget -c http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.14-rc-linux-glibc2.5-x86_64.tar.gz

解压并移动到安装目录

tar zxvf mysql-5.7.14-rc-linux-glibc2.5-x86_64.tar.gz

mv mysql-5.7.14-rc-linux-glibc2.5-x86_64 /data/apps/mysql

卸载mariadb

rpm -qa | grep mariadb

rpm -e mariadb-libs-5.5.50-1.el7_2.x86_64 --nodeps

创建数据库目录日志目录及设置权限

mkdir -p /home/data/mysql

mkdir -p /home/logs/mysql

chown -R mysql:mysql /home/logs/mysql

chmod 770 /home/data/mysql

chown -R mysql .

chgrp -R mysql .

chown -R root .

chown -R mysql:mysql /home/apps/mysql

初始化数据

cd /home/apps/mysql

./bin/mysqld --initialize-insecure --user=mysql --basedir=/home/apps/mysql --datadir=/home/data/mysql

配置my.ini

cat > /home/apps/mysql/my.cnf<<EOF

[client]

#password = your_password

port = 3306

socket = /tmp/mysql.sock

[mysqld]

port = 3306

socket = /tmp/mysql.sock

basedir = /home/apps/mysql

datadir = /home/data/mysql

character-set-server = utf8

log-error = /home/logs/mysql/error.log

skip-external-locking

key_buffer_size = 16M

max_allowed_packet = 1M

table_open_cache = 64

sort_buffer_size = 512K

net_buffer_length = 8K

read_buffer_size = 256K

read_rnd_buffer_size = 512K

myisam_sort_buffer_size = 8M

thread_cache_size = 8

query_cache_size = 8M

tmp_table_size = 16M

explicit_defaults_for_timestamp = true

#skip-networking

max_connections = 500

max_connect_errors = 100

open_files_limit = 65535

log-bin=mysql-bin

binlog_format=mixed

server-id = 1

expire_logs_days = 10

early-plugin-load = ""

default_storage_engine = InnoDB

[mysqldump]

quick

max_allowed_packet = 16M

[mysql]

no-auto-rehash

[myisamchk]

key_buffer_size = 20M

sort_buffer_size = 20M

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

EOF

sed -i "s#^key_buffer_size.*#key_buffer_size = 64M#" /home/apps/mysql/my.cnf

sed -i "s#^table_open_cache.*#table_open_cache = 256#" /home/apps/mysql/my.cnf

sed -i "s#^sort_buffer_size.*#sort_buffer_size = 1M#" /home/apps/mysql/my.cnf

sed -i "s#^read_buffer_size.*#read_buffer_size = 1M#" /home/apps/mysql/my.cnf

sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 16M#" /home/apps/mysql/my.cnf

sed -i "s#^thread_cache_size.*#thread_cache_size = 32#" /home/apps/mysql/my.cnf

sed -i "s#^query_cache_size.*#query_cache_size = 32M#" /home/apps/mysql/my.cnf

sed -i "s#^tmp_table_size.*#tmp_table_size = 64M#" /home/apps/mysql/my.cnf

sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 256M#" /home/apps/mysql/my.cnf

开机启动

cp support-files/mysql.server /etc/init.d/mysql

chmod 755 /etc/init.d/mysql

sed -i "s#^basedir=.*#basedir=/home/apps/mysql#" /etc/init.d/mysql

sed -i "s#^datadir=.*#datadir=/home/data/mysql#" /etc/init.d/mysql

chmod +x /etc/init.d/mysql

chkconfig --add mysql

chkconfig mysql on

//设置密码

/home/apps/mysql/bin/mysql --defaults-file=/home/apps/mysql/my.cnf -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');"

启动/停止/重启

service mysql start   service mysql stop   service mysql restart

 

评论

0条评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注