[MySQL]-二进制版安装-手册版

1.MySQL安装方式选择

  1.1 yum直接安装

    安装非常简单,适合对MySQL没有什么要求时使用.

         正常基本不考虑yum安装(开发本地装个客户端可以用),不能修改安装路径,导致一台服务器上只能安装一个MySQL,要安装新的需要先卸载

  1.2 rpm包安装

    可以选择MySQL版本进行下载. 与yum基本类似,不同只在于自己去下rpm安装包

    同yum

  1.2 二进制安装(免编译版)

    安装简单(相对源码安装而言,不用定向编译),相当于源码编译出一个通用版,对MySQL系统有基本的控制力,至少可以同时存在多个MySQL版本

    性能不如源码编译,因为源码编译可以定制编译参数,使得最后版本定向在某种环境或者某个操作系统而言有额外的运行效率提升.

  1.3 源码安装

    性能最高(统一的环境下),对MySQL系统干预力度最大(甚至可以自行分解组件等)

    编辑参数配置复杂,编译时间长,

  这里选择二进制安装,yum,rpm基本不考虑.也达不到需要定制编译来提高性能的程度

2.准备安装包

  mysql-5.6.23-linux-glibc2.5-x86_64.tar

       上传到服务器

3.安装

3.1安装到这里

  #mkdir /usr/local

  #mv /opt/software/mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz /usr/local/

  #cd /usr/local

3.2检查是否存在

  #ps -ef|grep mysqld

  #rpm -qa |grep -i mysql

3.3解压&&改名

  #tar xzvf mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz

  #mv mysql-5.6.23-linux-glibc2.5-x86_64 mysql

3.4创建用户组

  #groupadd -g 101 dba

3.5创建管理员

       #useradd -u 514 -g dba -G root -d /usr/local/mysql mysqladmin

  如果mysqladmin 已经存在#usermod -u 514 -g dba -G root -d /usr/local/mysql mysqladmin #

  检查一下 #id mysqladmin

  

  设置管理员密码#passwd mysqladmin

3.6 异步非阻塞接口组件

  #yum -y install libaio

3.7配置单独环境变量

  #cp /etc/skel/.* /usr/local/mysql

  #vi /etc/my.cnf

  覆盖以下内容

  

[client]
port = 3306
socket = /usr/local/mysql/data/mysql.sock

[mysqld]
port = 3306
socket = /usr/local/mysql/data/mysql.sock

skip-external-locking
key_buffer_size = 256M
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 4M
query_cache_size= 32M
max_allowed_packet = 16M
myisam_sort_buffer_size=128M
tmp_table_size=32M

table_open_cache = 512
thread_cache_size = 8
wait_timeout = 86400
interactive_timeout = 86400
max_connections = 600

# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 32

#isolation level and default engine
default-storage-engine = INNODB
transaction-isolation = READ-COMMITTED

server-id = 1
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
pid-file = /usr/local/mysql/data/hostname.pid

#open performance schema
log-warnings
sysdate-is-now

binlog_format = MIXED
log_bin_trust_function_creators=1
log-error = /usr/local/mysql/data/hostname.err
log-bin=/usr/local/mysql/arch/mysql-bin
#other logs
#general_log =1
#general_log_file = /usr/local/mysql/data/general_log.err
#slow_query_log=1
#slow_query_log_file=/usr/local/mysql/data/slow_log.err

#for replication slave
#log-slave-updates
#sync_binlog = 1

#for innodb options
innodb_data_home_dir = /usr/local/mysql/data/
innodb_data_file_path = ibdata1:500M:autoextend
innodb_log_group_home_dir = /usr/local/mysql/arch
innodb_log_files_in_group = 2
innodb_log_file_size = 200M

innodb_buffer_pool_size = 2048M
innodb_additional_mem_pool_size = 50M
innodb_log_buffer_size = 16M

innodb_lock_wait_timeout = 100
#innodb_thread_concurrency = 0
innodb_flush_log_at_trx_commit = 1
innodb_locks_unsafe_for_binlog=1

#innodb io features: add for mysql5.5.8
performance_schema
innodb_read_io_threads=4
innodb-write-io-threads=4
innodb-io-capacity=200
#purge threads change default(0) to 1 for purge
innodb_purge_threads=1
innodb_use_native_aio=on

#case-sensitive file names and separate tablespace
innodb_file_per_table = 1
lower_case_table_names=1

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[mysqlhotcopy]
interactive-timeout

[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

3.8环境配置文件提权

  #chown  mysqladmin:dba /etc/my.cnf

  #chmod  640 /etc/my.cnf

  检查一下#ll /etc/my.cnf

  

3.9变更独立环境配置文件给MySQL管理员

  #chown -R mysqladmin:dba /usr/local/mysql

  #chmod -R 755 /usr/local/mysql

4.MySQL初始化

  4.1 切换到MySQL管理员账户

  #su - mysqladmin

    看看 #pwd

    #mkdir arch 

  4.2 初始化

  #scripts/mysql_install_db  --user=mysqladmin --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 

5.设置开机自启动

  # cd /usr/local/mysql

  服务文件拷贝到init.d下,并重命名为mysql # cp support-files/mysql.server /etc/rc.d/init.d/mysql 

  赋予可执行权限 # chmod +x /etc/rc.d/init.d/mysql

  删除服务 # chkconfig --del mysql

  添加服务 # chkconfig --add mysql

  # chkconfig --level 345 mysql on

  

 6.启动MySQL

  还是切到MySQL管理员 # su - mysqladmin

  # rm -rf my.cnf

  # bin/mysqld_safe &

  

  

猜你喜欢

转载自www.cnblogs.com/NightPxy/p/9102964.html
今日推荐