MySql__centos6.5源码安装

安装MySql步骤如下:

  1. 依赖包检查安装
  2. 配置防火墙
  3. 配置hosts文件
  4. 配置sysctl.cnf
  5. 检查是否安装mysql 如果有卸载掉(指的是没有用的mysql)
  6. 创建用户属组
  7. 创建相应目录并修改权限
  8. 上传压缩包并解压
  9. 配置环境变量
  10. Cmake编译   make && make install
  11. 初始化数据库
  12. 开启服务并登陆,设置开机启动

1. 依赖包检查安装

rpm -q  cmake  make gcc  gcc-c++  bison   ncurses  ncurses-devel  openssl openssl-devel  boost-devel

yum -y install cmake  make gcc  gcc-c++  bison   ncurses  ncurses-devel  openssl  openssl-devel 

注意这里的boot版本需要1.59的  如果直接yum安装版本是不对的(1.53)

2. 配置防火墙

service iptables stop

chkconfig iptables off

vim  /etc/selinux/config

修改为SELINUX=disabled

3. 配置hosts文件

vim /etc/hosts   #看下hosts文件有没有配置过,没有的话 增加IP和 主机名,不然编译时候会报错提示hostsname识别不了的错误

4. 配置sysctl.cnf  (因为只是做测试,暂时不设置,需要可以去百度,我初学也不大董怎么设置最优)

5. 检查是否安装mysql 如果有卸载掉(指的是没有用的mysql)

[root@lscj ~]# rpm -qa| grep mysql

mysql-libs-5.1.71-1.el6.x86_64

[root@lscj ~]# rpm -e mysql-libs-5.1.71-1.el6.x86_64

6. 创建用户属组,配置环境变量

groupadd mysql

useradd -g mysql mysql

passwd mysql

id mysql

 

su - mysql

vim .bash_profile

 

MYSQL_HOME=/u01/app/mysql/mysql3306

PATH=$PATH:$MYSQL_HOME/bin

export PATH MYSQL_HOME

source .bash_profile

7. 创建相应目录并修改权限

mkdir -p /u01/app/mysql/mysql3306

mkdir -p /u01/app/mysql/mysql3306/data

mkdir -p /u01/app/mysql/mysql3306/log/iblog

mkdir -p /u01/app/mysql/mysql3306/log/binlog

mkdir -p /u01/app/mysql/mysql3306/run

mkdir -p /u01/app/mysql/mysql3306/temp

chown -R mysql:mysql /u01/app/mysql

 

8. 上传压缩包并解压

yum -y install lrzsz ftp工具

mysql安装包上传到/tmp/mysql下

tar -zxvf mysql-5.6.40.tar.gz

9. Cmake编译   make && make install

[mysql@lscj ~]$ cd /tmp/mysql/mysql-5.6.40

cmake \

-DCMAKE_INSTALL_PREFIX=/u01/app/mysql/mysql3306 \

-DINSTALL_DATADIR=/u01/app/mysql/mysql3306/data  \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DEXTRA_CHARSETS=all \

-DWITH_SSL=yes \

-DWITH_EMBEDDED_SERVER=1 \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITH_FEDERATED_STORAGE_ENGINE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DMYSQL_UNIX_ADDR=/u01/app/mysql/mysql3306/run/mysql.sock \

-DMYSQL_TCP_PORT=3306 \

-DENABLED_LOCAL_INFILE=1 \

-DSYSCONFDIR=/etc \

-DWITH_READLINE=on

 

make  && make install

之前的操作是root用户执行的,下面我们要进行赋权操作

chmod –R mysql:mysql /u01/app/mysql

11. 初始化数据库

./scripts/mysql_install_db --defaults-file=/u01/app/mysql/mysql3306/my.cnf --datadir=/u01/app/mysql/mysql3306/data --basedir=/u01/app/mysql/mysql3306  --user=mysql

12. 检查数据库初始化是否成功

cd到我们之前设置的 datadir路径下,看对应的文件夹是否生成

13.服务

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

这样以后就可以直接 service mysql status|start|stop 管理服务

 

 

 

最后附上我的参数文件信息

vim my.cnf

 

[client]
port=3306
socket=/u01/app/mysql/mysql3306/run/mysql.sock

[mysql]
#pid_file=/u01/app/mysql/mysql3306/run/mysqld.pid

[mysqld]
autocommit=0
general_log=off
explicit_defaults_for_timestamp=true

# system
basedir=/u01/app/mysql/mysql3306
datadir=/u01/app/mysql/mysql3306/data
max_allowed_packet=1g
max_connections=3000
max_user_connections=2800
open_files_limit=65535
pid_file=/u01/app/mysql/mysql3306/run/mysqld.pid
port=3306
server_id=101
skip_name_resolve=ON
socket=/u01/app/mysql/mysql3306/run/mysql.sock
tmpdir=/u01/app/mysql/mysql3306/tmp

#binlog
log_bin=/u01/app/mysql/mysql3306/log/binlog
binlog_cache_size=32768
binlog_format=row
expire_logs_days=7
log_slave_updates=ON
max_binlog_cache_size=2147483648
max_binlog_size=524288000
sync_binlog=100

#logging
log_error=/u01/app/mysql/mysql3306/log/error.log
slow_query_log_file=/u01/app/mysql/mysql3306/log/slow.log
log_queries_not_using_indexes=0
slow_query_log=1
log_slave_updates=ON
log_slow_admin_statements=1
long_query_time=1


#relay
relay_log=/u01/app/mysql/mysql3306/log/relaylog
relay_log_index=/u01/app/mysql/mysql3306/log/relay.index
relay_log_info_file=/u01/app/mysql/mysql3306/log/relay-log.info

#slave
slave_load_tmpdir=/u01/app/mysql/mysql3306/tmp
slave_skip_errors=OFF


#innodb
innodb_data_home_dir=/u01/app/mysql/mysql3306/log/iblog
innodb_log_group_home_dir=/u01/app/mysql/mysql3306/log/iblog
innodb_adaptive_flushing=ON
innodb_adaptive_hash_index=ON
innodb_autoinc_lock_mode=1
innodb_buffer_pool_instances=8

#default
innodb_change_buffering=inserts
innodb_checksums=ON
innodb_buffer_pool_size= 128M
innodb_data_file_path=ibdata1:32M;ibdata2:16M:autoextend
innodb_doublewrite=ON
innodb_file_format=Barracuda
innodb_file_per_table=ON
innodb_flush_log_at_trx_commit=1
innodb_flush_method=O_DIRECT
innodb_io_capacity=1000
innodb_lock_wait_timeout=10
innodb_log_buffer_size=67108864
innodb_log_file_size=1048576000
innodb_log_files_in_group=4
innodb_max_dirty_pages_pct=60
innodb_open_files=60000
innodb_purge_threads=1
innodb_read_io_threads=4
innodb_stats_on_metadata=OFF
innodb_support_xa=ON
innodb_use_native_aio=OFF
innodb_write_io_threads=10

[mysqld_safe]
datadir=/u01/app/mysql/mysql3306/data

posted @ 2018-05-26 15:28  maskedguy  阅读(142)  评论(0编辑  收藏  举报