如果是要安装mariadb的话,不用看下面了,默认就是。直接yum安装应该就可以。
Mysql 的话,默认的源里面已经没有了,只能是下载下来rpm包进行安装,之前选择错了版本下载的,能安上,不过用不了(其实是不会用),各种坑啊反正是,坑了一天多的时间。为了节省时间赶紧搞啊,就换了个简单直接的方法,希望对大家有帮助。
1、下载rpm包
在http://dev.mysql.com/downloads/mysql/
centos 7 请选择
red hat interprise linux/oracle
后缀为 .rpm-bundle.tar
下载好后 (mysql 为下载好的文件 一般为mysql-xxxxx.rpm-bundle.tar)
[root@localhost local]# tar -xvf mysql mysql-community-minimal-debuginfo-5.7.20-1.el7.x86_64.rpm mysql-community-embedded-5.7.20-1.el7.x86_64.rpm mysql-community-libs-compat-5.7.20-1.el7.x86_64.rpm mysql-community-libs-5.7.20-1.el7.x86_64.rpm mysql-community-embedded-compat-5.7.20-1.el7.x86_64.rpm mysql-community-devel-5.7.20-1.el7.x86_64.rpm mysql-community-server-5.7.20-1.el7.x86_64.rpm mysql-community-server-minimal-5.7.20-1.el7.x86_64.rpm mysql-community-client-5.7.20-1.el7.x86_64.rpm mysql-community-test-5.7.20-1.el7.x86_64.rpm mysql-community-common-5.7.20-1.el7.x86_64.rpm mysql-community-embedded-devel-5.7.20-1.el7.x86_64.rpm
因为依赖关系 ,我们先安装 mysql-community-common-5.7.20-1.el7.x86_64.rpm (5.7.20 是我安装时的版本号)
rpm -ivh mysql-community-common-5.7.20-1.el7.x86_64.rpm
如果提示下面的内容
file /usr/share/mysql/charsets/swe7.xml from install of mysql-community-common-5.7.20-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.56-2.el7.x86_64
里面提示有
mariadb-libs
那就应该是还有 mariadb 的残党存在。
grep -i mariadb
卸载
rpm -ev mariadb-libs-5.5.56-2.el7.x86_64 --nodeps
卸载完了别忘了把最上面的包再安装一次
继续
rpm -ivh mysql-community-libs-5.7.20-1.el7.x86_64.rpm
客户端安装
rpm -ivh mysql-community-client-5.7.20-1.el7.x86_64.rpm
server端 rpm -ivh mysql-community-server-5.7.20-1.el7.x86_64.rpm
启动mysql
service mysqld start
查看状态
service mysqld status
OK就OK了
cat /var/log/mysqld.log
里面有密码 (找找password就行了)
登陆
mysql -uroot -p
输入密码
welocome mysql‘s world..
如果需要修改密码
SET PASSWORD = PASSWORD(‘mysqlPassword123+-*/123123‘);