在Centos7下使用rpm安装下mysql的流程: 首先进入mysql官网的下载地址: https://dev.mysql.com/downloads/mysql/,然后在下载里面把os选择为Red Hat Enterprise Linux 7 / Oracle Linux 7 ,把os的版本选择为all。 在下方的下载链接找到以下文件:
mysql-community-client-5.7.19-1.el7.x86_64.rpm
mysql-community-common-5.7.19-1.el7.x86_64.rpm
mysql-community-devel-5.7.19-1.el7.x86_64.rpm
mysql-community-libs-5.7.19-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.19-1.el7.x86_64.rpm
mysql-community-server-5.7.19-1.el7.x86_64.rpm
因为我是Centos7 64位版本,所以选择了以上文件,如果你主机是Centos6 或者是32位版本,请找到对应版本文件,然后把六个文件下载齐全。 接下来依次按以下命令按顺序安装这些文件:
rpm -ivh mysql-community-common-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.19-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.19-1.el7.x86_64.rpm
至此,mysql5.7所有文件安装完毕,接下来就是开启服务测试了。
1.首先关闭mysql服务:
service mysqld stop(systemctl stop mysqld.service)
2.然后修改配置文件:
vim /etc/my.cnf
3.接下来加入一句代码即可空密码登录mysql:
4.开启mysql服务:
service mysqld start (systemctl start mysqld.service)
5.空密码登录mysql:
mysql -u root -p #输入命令回车进入,出现输入密码提示直接回车
6.设置mysql密码:
远程修改登入密码
7.设置mysql开机自启:
systemctl enable mysqld