標籤:MySQL5.7 OEL6.9 MySQL二進位安裝
前提準備 (關閉防火牆,selinux,安裝libaio)shell> chkconfig --level 2345 iptables offshell> service iptables stopshell> vi /etc/selinux/configSELINUX=disabled
shell> yum install libaio
1. 配置使用者屬組 (MySQL使用者不需要登入作業系統)
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
2. 解壓二進位軟體
shell> cd /usr/local
shell> mv ~/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz ./
shell> tar zxvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
or
shell> gunzip < mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz | tar xvf -
shell> mv mysql-5.7.21-linux-glibc2.12-x86_64 mysql-5.7.21
3. 修改軟體許可權建立連結
shell> chmod -R 750 ./mysql-5.7.21
shell> chown -R mysql:mysql ./mysql-5.7.21
shell> ln -s /usr/local/mysql-5.7.21 mysql
4. 建立MySQL資料目錄 (提前touch記錄檔,否則啟動的時候會報錯)
shell> mkdir -p /mysql/{data,log,binlog}
shell> chown -R mysql:mysql /mysql/
shell> touch /mysql/log/mysqld.log
shell> chown mysql:mysql /mysql/log/mysqld.log
5. 編輯資料庫伺服器參數 (指定資料初始化目錄,也可以通過命令列指定初始化目錄)
shell> vi /etc/my.cnf
[mysqld]
datadir=/mysql/data
socket=/mysql/log/mysql.sock
[mysqld_safe]
log_error=/mysql/log/mysqld.log
pid_file=/mysql/log/mysqld.pid
6. 初始化資料庫
shell> cd mysql
shell> bin/mysqld --initialize --user=mysql (m3gfb<1gKDZ%)
shell> bin/mysql_ssl_rsa_setup
shell> bin/mysqld_safe --user=mysql &
7. 修改預設root口令
[[email protected] mysql]# mysql -u root -p -S /mysql/log/mysql.sock
mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘oracle‘;
mysql> FLUSH PRIVILEGES;
8. 關閉資料庫`[[email protected] mysql]# bin/mysqladmin -u root -p -S /mysql/log/mysql.sock shutdown`9. 修改環境變數
shell> vi ~/.bash_profile
export PATH=/usr/local/mysql/bin:$PATH
export MYSQL_PS1="(\[email protected]\h) [\d]> "
[[email protected] mysql]# . ~/.bash_profile
10. 配置MySQL服務
shell> cp support-files/mysql.server /etc/init.d/mysql
shell> chkconfig --add mysql
shell> chkconfig --level 2345 mysql on
11. 編輯資料庫用戶端參數
[client]
host=localhost
user=root
password=oracle
socket=/mysql/log/mysql.sock
12. 啟動MySQL服務`shell> service mysql start`13. 登入資料庫驗證
shell> mysql
([email protected]) [(none)]> show databases;
錯誤解決:1.
2018-03-15T13:38:06.902460Z 0 [ERROR] SSL error: Unable to get private key from ‘server-key.pem‘
2018-03-15T13:38:06.902470Z 0 [Warning] Failed to set up SSL because of the following SSL library error: Unable to get private key
mysql使用者沒有許可權訪問‘server-key.pem‘檔案,修改許可權後錯誤解決:
[[email protected] security]# cd /mysql/data/
[[email protected] data]# ls -la server-key.pem
-rw------- 1 root root 1679 Mar 15 21:24 server-key.pem
[[email protected] data]# chmod 644 server-key.pem
[[email protected] data]# service mysql restart
2018-03-15T14:29:38.605619Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
null
2.
2018-03-15T13:38:06.767757Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_time
stamp server option (see documentation for more details).
通過設定參數解決該警示:
explicit_defaults_for_timestamp=1
Note
explicit_defaults_for_timestamp is itself deprecated because its only purpose is to permit control over deprecated TIMESTAMP behaviors that are to be removed in a future MySQL release. When removal of those behaviors occurs, explicit_defaults_for_timestamp will have no purpose and will be removed as well.
MySQL 5.7.21 在 OEL6.9 平台上的二進位安裝