1.关闭selinux 服务【SELinux是一种基于域-类型 模型(domain-type)的强制访问控制(MAC)安全系统】
[root@linuxidc ~]# vim /etc/selinux/config
···
SELINUX=disabled
···
2.关闭防火墙服务,并且禁用开机启动
[root@linuxidc ~]# systemctl stop firewalld.service
[root@linuxidc ~]# systemctl disable firewalld.service
3.关闭NetworkManager服务,并且禁用开机启动【(NetworManager)是检测网络、自动连接网络的程序】
[root@linuxidc ~]# systemctl stop NetworkManager.service
[root@linuxidc ~]# systemctl disable NetworkManager.service
4.检查系统是否安装有MysqL的安装包,如果有使用rpm -e 移除
[root@linuxidc ~]# rpm -qa| grep MysqL
5.下载MysqL5.6的安装包,并上传到服务器上
[root@linuxidc 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@linuxidc MysqL]# rpm -ivh MysqL-server-5.6.31-1.el7.x86_64.rpm
[root@linuxidc MysqL]# rpm -ivh MysqL-devel-5.6.31-1.el7.x86_64.rpm
[root@linuxidc MysqL]# rpm -ivh MysqL-client-5.6.31-1.el7.x86_64.rpm
7.修改my.cnf配置文件位置
[root@linuxidc ~]# cp /usr/share/MysqL/my-default.cnf /etc/my.cnf
8.修改字符集和数据存储路径 配置/etc/my.cnf文件,设置如下键值来启用一起有用的选项和 UTF-8 字符集.
[root@linuxidc ~]# cat /etc/my.cnf
[MysqLd]
···
innodb_file_per_table
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
9.初始化MysqL及设置密码
[root@linuxidc ~]# /usr/bin/MysqL_install_db
[root@linuxidc ~]# service MysqL start
[root@linuxidc ~]# cat /root/.MysqL_secret
# The random password set for the root user at Mon Dec 26 20:43:34 2016 (local time): 1dwIOrYEiaPsCyTM
[root@linuxidc ~]# MysqL -uroot -p1dwIOrYEiaPsCyTM
MysqL> SET PASSWORD = PASSWORD('abcd1234');
Query OK,0 rows affected (0.00 sec)
10.设置MysqL开机启动
[root@linuxidc ~]# systemctl restart MysqLd.service
[root@linuxidc ~]# systemctl enable MysqLd.service
11.设置MysqL允许远程登陆
12.安装MysqL出现安装包不兼容问题
[root@linuxidc 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@linuxidc MysqL]# rpm -qa |grep mariadb* mariadb-libs-5.5.41-2.el7_0.x86_64 [root@linuxidc 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@linuxidc MysqL]# yum remove mariadb-libs* -y
原文链接:/centos/375999.html