標籤:二進位方式 安裝mysql5.6.39 Centos 7+mysql5.6
系統平台:CentOS release 7.4 (Final) 核心 3.10.0-693.el7.x86_641.去官網下載二進位包
https://dev.mysql.com/downloads/mysql/
2.建立用於啟動mysql的帳號和組
#getent group mysql > /dev/null || groupadd mysql#getent passwd mysql > /dev/null || useradd -g mysql -r -s /sbin/nologin mysql
3.解壓包至/usr/local
#tar xvf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
4.建立軟連結mysql指向解壓後的目錄
#cd /usr/local/#ln -sv mysql-5.6.39-linux-glibc2.12-x86_64/ mysql
5.修改mysql檔案夾所屬者和所屬組
#chown -R mysql.mysql mysql/
6.添加PATH至環境變數中
#echo ‘PATH=/usr/local/mysql/bin:$PATH‘ >> /etc/profile.d/mysql.sh檢查檔案#cat /etc/profile.d/mysql.sh載入環境變數檔案 並檢查#source /etc/profile.d/mysql.sh#echo $PATH
7.建立資料庫存放檔案夾和相關檔案並修改許可權
# mkdir -pv /data/mysqldb/3306/{logs,bin-logs,run,data}# touch /data/mysqldb/3306/run/mysqld.pid# touch /data/mysqldb/3306/logs/mysql-error.log# chown -R mysql.mysql /data/mysqldb/ -R# chmod -R 770 /data/mysqldb/# chown -R mysql.mysql /data/mysqldb/# chmod -R 770 /data/mysqldb檔案沒有建立的話,啟動Mysql時將會報錯
8.修改設定檔
#vim /etc/my.cnf[client]port = 3306socket = /tmp/mysql.sockdefault-character-set=utf8[mysqld]user = mysqlport = 3306basedir=/usr/local/mysqldatadir = /data/mysqldb/3306/datasocket = /tmp/mysql.socklog-bin = /data/mysqldb/3306/bin-logs/mysql-binbinlog_format=mixedsymbolic-links=0innodb_file_per_table = 1skip_name_resolve = 1slow_query_log = 1long_query_time = 2pid-file = /data/mysqldb/3306/run/mysqld.pidlog-error = /data/mysqldb/3306/logs/mysql-error.logcharacter-set-server=utf8default-storage-engine=INNODB[mysqld_safe]# include all files from the config directory#!includedir /etc/my.cnf.d
9.初始化資料庫
# cd /usr/local/mysql# bin/mysqld --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysqldb/3306/data
10.複製啟動服務指令碼至/etc/init.d目錄(小坑)
使用二進位安裝包裡面的support-files/mysql.server這個啟動指令碼死活不能啟動,報以下錯誤Starting MySQL. ERROR! The server quit without updating PID file (/data/mysqldb/3306/run/mysqld.pid).無奈之下,去mysql官網下載一個mysql的源碼包,使用裡面的mysql.server就沒問題。呵呵。#cp mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
11.添加開機啟動
# chkconfig --add mysqld# chkconfig mysqld on#chkconfig --list mysqldmysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
12.啟動mysql服務
#service mysqld startStarting MySQL. SUCCESS!
13.檢查確認
檢查3306連接埠是否開啟
#ss -ntl | grep 3306LISTEN 0 50 *:3306 *:*
確認版本
# mysql -Vmysql Ver 14.14 Distrib 5.6.39, for linux-glibc2.12 (x86_64) using EditLine wrapper
14.進行安全配置
#/usr/local/mysql/bin/mysql_secure_installation按提示操作即可
15.用戶端串連
#mysql -uroot -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 14Server version: 5.6.39-log MySQL Community Server (GPL)Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql>
CentOS 7.4 自訂單一實例 二進位方式 安裝mysql5.6.39