mysql5.6源码部署

一.准备环境

环境:centos-7.3 一台
软件版本:mysql-5.6.39

1.安装依赖
yum -y install autoconf libaio bison ncurses-devel

2.创建用户
groupadd mysql
useradd -g mysql -s /sbin/nologin mysql

3.清理centos7 默认自带数据库
yum -y remove mariadb mariadb-server

二.部署

1.下载MySQL
wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz

2.安装
tar -xf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz

mv mysql-5.6.39-linux-glibc2.12-x86_64 /usrlocal/mysql
mkdir /var/log/mysql
mkdir /usr/local/mysql/data

mysql即使root启动还是mysql用户运行的,所以要给权限
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /ops/log/mysql

3.修改配置,具体再根据性能和需求修改
vim /etc/my.cnf

[mysql]
default-character-set=utf8
socket=/usr/local/mysql/mysql.sock
[mysqld]
skip-name-resolve
port = 3306
socket=/usr/local/mysql/mysql.sock
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
max_connection=200
character-set-server=utf8
default-storage-engine=INNODB
lower_case_table_name=1
max_allowed_packet=16M
log-error=/var/log/mysql/mysql.log
pid-file=/var/log/mysql/mysql.pid
bind-address = 0.0.0.0

4.启动服务
cd /usr/local/mysql

进行初始化操作
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

让mysql可以读
chown mysql:mysql /etc/my.cnf

5.加入systemctl
vim /usr/lib/systemd/system/mysql.service

[Unit]
Description=mysql
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/local/mysql/support-files/mysql.server start
ExecReload=/usr/local/mysql/support-files/mysql.server restart
ExecStop=/usr/local/mysql/support-files/mysql.server stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target

6.设置环境变量
echo 'PATH=$PATH':/usr/local/mysql/bin >> /etc/profile
source /etc/profile

7.登陆
systemctl start mysql
systemctl enable mysql

 

posted @ 2019-01-04 14:50  禾子、  阅读(305)  评论(0编辑  收藏  举报