在centos 6.9 上rpm安装MysqL
环境:
Linux:CentOS release 6.9 64bit
MysqL: mysq-5.7.18
1、在/home创建MysqL目录,下载如下四个软件包
http://mirrors.sohu.com/MysqL/MysqL-5.7/
wget http://mirrors.sohu.com/MysqL/MysqL-5.7/MysqL-community-client-5.7.18-1.el6.x86_64.rpm
wget http://mirrors.sohu.com/MysqL/MysqL-5.7/MysqL-community-common-5.7.18-1.el6.x86_64.rpm
wget http://mirrors.sohu.com/MysqL/MysqL-5.7/MysqL-community-libs-5.7.18-1.el6.x86_64.rpm
wget http://mirrors.sohu.com/MysqL/MysqL-5.7/MysqL-community-server-5.7.18-1.el6.x86_64.rpm
[root@centos-6 MysqL]# rpm -qa | grep -i MysqL
MysqL-libs-5.1.73-8.el6_8.x86_64
[root@centos-6 MysqL]# rpm -e MysqL-libs-5.1.73-8.el6_8.x86_64
error: Failed dependencies:
libMysqLclient.so.16()(64bit) is needed by (installed) postfix-2:2.6.6-8.el6.x86_64
libMysqLclient.so.16(libMysqLclient_16)(64bit) is needed by (installed) postfix-2:2.6.6-8.el6.x86_64
MysqL-libs is needed by (installed) postfix-2:2.6.6-8.el6.x86_64
[root@centos-6 MysqL]#
将依赖包一并删除
[root@centos-6 MysqL]# yum remove -y MysqL-libs
[root@centos-6 MysqL]# rpm -qa | grep -i MysqL
[root@centos-6 MysqL]#
3、同时安装这四个rpm包
rpm -ivh MysqL-community-client-5.7.18-1.el6.x86_64.rpm MysqL-community-common-5.7.18-1.el6.x86_64.rpm MysqL-community-libs-5.7.18-1.el6.x86_64.rpm MysqL-community-server-5.7.18-1.el6.x86_64.rpm
4、出现缺少依赖包解决方式
[root@centos-6 home]# rpm -ivh MysqL-community-client-5.7.18-1.el6.x86_64.rpm MysqL-community-common-5.7.18-1.el6.x86_64.rpm MysqL-community-libs-5.7.18-1.el6.x86_64.rpm MysqL-community-server-5.7.18-1.el6.x86_64.rpm
warning: MysqL-community-client-5.7.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature,key ID 5072e1f5: NOKEY
error: Failed dependencies:
libnuma.so.1()(64bit) is needed by MysqL-community-server-5.7.18-1.el6.x86_64
libnuma.so.1(libnuma_1.1)(64bit) is needed by MysqL-community-server-5.7.18-1.el6.x86_64
libnuma.so.1(libnuma_1.2)(64bit) is needed by MysqL-community-server-5.7.18-1.el6.x86_64
[root@centos-6 home]# yum install -y numactl
5、密码获取
第一次通过#grep "password" /var/log/MysqLd.log 命令获取MysqL的临时密码
用该密码登录到服务端后,必须马上修改密码,不然操作查询时报错误
刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
如果想设置简单密码,如下操作:
首先,修改validate_password_policy参数的值
MysqL> set global validate_password_policy=0; #定义复杂度
MysqL> set global validate_password_length=1; #定义长度 默认是8
MysqL>set password for 'root'@'localhost'=password('123456'); #设置root密码为123456
MysqL> flush privileges;#刷新权限使配置生效