老的办法,已经不适合了,所以这里做一些调整,后面都用红色标记出来。
1.Yum包的官方地址:
https://dev.mysql.com/downloads/repo/yum/
选择对应系统的rpm包下载 下载的时候要登录的时候,请注册一个。这里可以不需注册了,在注册的下方,有一个“No thanks, just start my download.”点击就可以下载
然后,把对应的rpm包下载下来
2:然后把rpm包,传到linux系统,centos 6,7是有区分的,请对系统做相应的操作。
CentOS7:https://repo.mysql.com//mysql80-community-release-el7-2.noarch.rpm
CentOS6:https://repo.mysql.com//mysql80-community-release-el6-2.noarch.rpm
Centos7 :mysql57-community-release-el7-11.noarch.rpm
Centos6:mysql57-community-release-el6-11.noarch.rpm
3:解压安装rpm
输入su,进入root模式
输入:rpm -Uvh xxxxxx.rpm安装对应的yum包
输入:yum repolist all | grep mysql
这个时候,可以看到很多mysql的配置
mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community disabled
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - disabled
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community disabled
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - disabled
mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 95
mysql-connectors-community-source MySQL Connectors Community - disabled
mysql-tools-community/x86_64 MySQL Tools Community enabled: 84
mysql-tools-community-source MySQL Tools Community - Sourc disabled
mysql-tools-preview/x86_64 MySQL Tools Preview disabled
mysql-tools-preview-source MySQL Tools Preview - Source disabled
mysql55-community/x86_64 MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - disabled
mysql56-community/x86_64 MySQL 5.6 Community Server disabled
mysql56-community-source MySQL 5.6 Community Server - disabled
mysql57-community/x86_64 MySQL 5.7 Community Server enabled: 327
mysql57-community-source MySQL 5.7 Community Server - disabled
mysql80-community/x86_64 MySQL 8.0 Community Server disabled
mysql80-community-source MySQL 8.0 Community Server - disabled
然后配置一下安装源:
# yum-config-manager --disable mysql80-community
# yum-config-manager --enable mysql57-community
其它的版本,你可以自行安装了,如果没有yum-config-manager命令,可以如下安装:
# yum install yum-utils
然后就可以用这个yum-config-manager
4.安装
安装mysql:yum install mysql-community-server
5.启动
启动mysql:service mysqld start
6.设置密码
注意一下:数据库初始化,必须要重置密码才能使用,也就是使用alter user命令将root密码重置。
输入:grep 'temporary password' /var/log/mysqld.log查看密码
然后输入:mysql -uroot -p连接本地的mysql,提示输入的密码,就是那个上面grep命令显示的
进入mysql后,用下面的命令修改密码:
mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
安装完成后,安装的数据在:/var/lib/mysql
1、关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
//配置连接方式和权限,注意,要执行flush privileges;否则会连接不了
grant all on *.* to rock@'%' identified by 'NewPassword1' with grant option;
flush privileges;