linux 環境RPM 安裝MYSQL5.6
系統環境 CentOS7.2
1.關閉selinux 服務【SELinux是一種基於域-類型 模型(domain-type)的強制訪問控制(MAC)安全系統】
[root@OperationsAnalysis ~]# vim /etc/selinux/config ··· SELINUX=disabled ···
2.關閉防火牆服務,並且禁用開機啟動
[root@OperationsAnalysis ~]# systemctl stop firewalld.service [root@OperationsAnalysis ~]# systemctl disable firewalld.service
3.關閉NetworkManager服務,並且禁用開機啟動【(NetworManager)是檢測網絡、自動連接網絡的程序】
[root@OperationsAnalysis ~]# systemctl stop NetworkManager.service [root@OperationsAnalysis ~]# systemctl disable NetworkManager.service
4.檢查系統是否安裝有mysql的安裝包,如果有使用rpm -e 移除
[root@OperationsAnalysis ~]# rpm -qa| grep mysql
5.下載mysql5.6的安裝包,並上傳到服務器上
[root@OperationsAnalysis mysql]# ll total 236180 -rw-r--r-- 1 root root 20278972 Sep 22 15:41 MySQL-client-5.6.31-1.el7.x86_64.rpm -rw-r--r-- 1 root root 3529244 Sep 22 15:40 MySQL-devel-5.6.31-1.el7.x86_64.rpm -rw-r--r-- 1 root root 92246408 Sep 22 15:44 MySQL-embedded-5.6.31-1.el7.x86_64.rpm -rw-r--r-- 1 root root 61732192 Sep 22 15:42 MySQL-server-5.6.31-1.el7.x86_64.rpm -rw-r--r-- 1 root root 2101912 Sep 22 15:42 MySQL-shared-5.6.31-1.el7.x86_64.rpm -rw-r--r-- 1 root root 2299648 Sep 22 15:40 MySQL-shared-compat-5.6.31-1.el7.x86_64.rpm -rw-r--r-- 1 root root 59644132 Sep 22 15:40 MySQL-test-5.6.31-1.el7.x86_64.rpm
6.安裝mysql 的安裝包
[root@OperationsAnalysis mysql]# rpm -ivh MySQL-server-5.6.31-1.el7.x86_64.rpm [root@OperationsAnalysis mysql]# rpm -ivh MySQL-devel-5.6.31-1.el7.x86_64.rpm [root@OperationsAnalysis mysql]# rpm -ivh MySQL-client-5.6.31-1.el7.x86_64.rpm
7.修改my.cnf配置文件位置
[root@OperationsAnalysis ~]# cp /usr/share/mysql/my-default.cnf /etc/my.cnf
8.修改字符集和數據存儲路徑 配置/etc/my.cnf文件,設置如下鍵值來啟用一起有用的選項和 UTF-8 字符集.
[root@OperationsAnalysis ~]# cat /etc/my.cnf [mysqld] ··· innodb_file_per_table max_connections = 4096 collation-server = utf8_general_ci character-set-server = utf8
9.初始化MySQL及設置密碼
[root@OperationsAnalysis ~]# /usr/bin/mysql_install_db
[root@OperationsAnalysis ~]# service mysql start [root@OperationsAnalysis ~]# cat /root/.mysql_secret # The random password set for the root user at Mon Dec 26 20:43:34 2016 (local time): 1dwIOrYEiaPsCyTM [root@OperationsAnalysis ~]# mysql -uroot -p1dwIOrYEiaPsCyTM mysql> SET PASSWORD = PASSWORD('abcd1234'); Query OK, 0 rows affected (0.00 sec)
10.設置mysql開機啟動
[root@OperationsAnalysis ~]# systemctl restart mysqld.service [root@OperationsAnalysis ~]# systemctl enable mysqld.service
11.設置mysql允許遠程登陸
12.安裝mysql出現安裝包不兼容問題
[root@OperationsAnalysis mysql]# rpm -ivh MySQL-server-5.6.31-1.el7.x86_64.rpm
warning: MySQL-server-5.6.31-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
file /usr/share/mysql/charsets/README from install of MySQL-server-5.6.31-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64 file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.31-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64 file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.6.31-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64 file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.6.31-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64
解決方法,刪除不兼容安裝包
[root@OperationsAnalysis mysql]# rpm -qa |grep mariadb* mariadb-libs-5.5.41-2.el7_0.x86_64 [root@OperationsAnalysis mysql]# rpm -e mariadb-libs-5.5.41-2.el7_0.x86_64 (有依賴包,建議使用yum移除) error: Failed dependencies: libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64 libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64 [root@OperationsAnalysis mysql]# yum remove mariadb-libs* -y