Cent Os 6.5二进制版快速安装配置MYSQL5.6

一、安装说明

1.Mysql安装方式有源码、RPM、yum、二进制安装,这里采用二进制安装,

  网上调研二进制安装和源码安装后的性能差不多,

  但二进制安装包是编译好的直接可执行的mysql程序文件。

2.安装的系统是Linux Cent Os 6.5  (2核、2G内存)

3.Mysql版本 目前最新为5.6.31

4.Mysql 安装根目录 /opt/mysql

   数据文件目录为 /opt/mysql/data

   配置文件存放在 /etc/my.cnf

二、Mysql参数文件 my.cnf配置

my.cnf中的各参数配置参考如下:

[client]

port = 3306

socket = /opt/mysql/mysql.sock

[mysqld]

port = 3306

socket = /opt/mysql/mysql.sock

basedir = /opt/mysql

datadir = /opt/mysql/data

skip-external-locking

key_buffer_size = 32M

max_allowed_packet = 16M

table_open_cache = 512

net_buffer_length = 8K

read_buffer_size = 2M

read_rnd_buffer_size = 8M

myisam_sort_buffer_size = 8M

lower_case_table_names= 1

init_connect='SET NAMES utf8mb4'

log_bin_trust_function_creators=1

innodb_buffer_pool_size=1024M

innodb_log_file_size=256M

innodb_io_capacity=500

innodb_io_capacity_max=700

innodb_lru_scan_depth=2000

innodb_lock_wait_timeout = 200

innodb_file_per_table=1

主从配置记得server-id需要补同

server-id= 1

#Binary log/replication

#log-bin=mysql-bin

#binlog-do-db=test_mysql

#binlog-ignore-db=mysql

#binlog-do-db=merchantdb

sync_binlog=1

sync_relay_log=1

relay-log-info-repository=TABLE

master-info-repository=TABLE

expire_logs_days=5

binlog_format=ROW

transaction-isolation=READ-COMMITTED

innodb_autoinc_lock_mode = 2

character-set-server=utf8mb4

collation-server=utf8mb4_general_ci

max-connect-errors=500

max-connections=200

[mysqldump]

socket = /opt/mysql/mysql.sock

quick

max_allowed_packet = 16M

[mysql]

no-auto-rehash

# Remove the next comment character if you are not familiar with SQL

#safe-updates

[myisamchk]

key_buffer_size = 20M

sort_buffer_size = 20M

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout

[mysqld_multi]

mysqld = /opt/mysql/bin/mysqld_safe

mysqladmin = /opt/mysql/bin/mysqladmin

#log = /var/log/mysqld_multi.log

# user = multi_admin

# password = secret


三、具体参考步骤

安装包下载网址:http://dev.mysql.com/downloads/mysql/5.6.html#downloads

选择二进制格式(Generic)的安装包,如:mysql-5.6.31-linux-glibc2.5-x86_64.tar.gz

具体步骤参考如下:

[root@i-testdb opt]# pwd

/opt

[root@i-testdb opt]# tar -xvf mysql-5.6.31-linux-glibc2.5-x86_64.tar.gz

[root@i-testdb opt]# mv mysql-5.6.31-linux-glibc2.5-x86_64 mysql

[root@i-testdb opt]# groupadd mysql

[root@i-testdb opt]# useradd -g mysql mysql

[root@i-testdb opt]# cd ./mysql

[root@i-testdb mysql]# chown -R mysql:mysql .

[root@i-testdb mysql]# yum install libaio.so.1

[root@i-testdb mysql]# yum install libncurses.so.5

[root@i-testdb mysql]# vi /etc/profile

# 添加环境变量,/etc/profile文件内容底部添加如下两行信息

# mysql env

export PATH=$PATH:/opt/mysql/bin

# 初始化mysql数据库

[root@i-testdb mysql]#

./scripts/mysql_install_db

--user=mysql

--basedir=/opt/mysql

--datadir=/opt/mysql/data/

[root@i-testdb mysql]# cp ./support-files/mysql.server /etc/init.d/mysqld

启动mysql 有以下两种方式:

[root@i-testdb mysql]# /etc/init.d/mysqld start

# 或者

[root@i-testdb mysql]# service mysqld start

# root用户设置密码

[root@i-testdb mysql]# /opt/mysql/bin/mysqladmin -u root password 'root123'

# sock文件创建在/tmp文件目录下单链接,有些程序需要用到

[root@i-testdb mysql]# ln -s /opt/mysql/mysql.sock /tmp/mysql.sock

# mysql 提供的一些初始化后数据库安全建议,这个需要/tmp下的mysql.sock文件

[root@i-testdb mysql]#  /opt/mysql/bin/mysql_secure_installation


至此,mysql二进制安装完成!





你可能感兴趣的:(mysql,mysql,二进制,linux,centos)