本章我们来介绍如何使用rpm方式安装Mysql5.7,快捷方便,省时高效
正文:
第一步:准备环境
1、查看linux上是否已经安装了mysql,有则卸载
rpm -qa |grep mysql
rpm -qa |grep postfix
rpm -qa |grep mariadb
#卸载命令
rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
2、安装mysql5.7所需要的依赖
yum -y install libaio
yum -y install net-tools
yum -y install perl
第二步:上传我们的rpm包到home目录下并安装
1、切换到home目录解压文件
[root@hecs-x-medium-2-linux-20200621092116 home]# tar -xvf mysql-5.7.19-1.el6.x86_64.rpm-bundle.tar
2、安装mysql-community-common-5.7.19-1.el6.x86_64.rpm文件
[root@hecs-x-medium-2-linux-20200621092116 home]# rpm -ivh mysql-community-common-5.7.19-1.el6.x86_64.rpm
3、安装mysql-community-libs-5.7.19-1.el6.x86_64.rpm文件
[root@hecs-x-medium-2-linux-20200621092116 home]# rpm -ivh mysql-community-libs-5.7.19-1.el6.x86_64.rpm
4、安装mysql-community-client-5.7.19-1.el6.x86_64.rpm文件
[root@hecs-x-medium-2-linux-20200621092116 home]# rpm -ivh mysql-community-client-5.7.19-1.el6.x86_64.rpm
5、安装mysql-community-server-5.7.19-1.el6.x86_64.rpm文件
[root@hecs-x-medium-2-linux-20200621092116 home]# rpm -ivh mysql-community-server-5.7.19-1.el6.x86_64.rpm --force --nodeps
安装完成:
***如果安装时遇到key id异常,则在命令后添加 --force --nodeps 即可
第三步:查看mysql安装是否成功并启动
[root@hecs-x-medium-2-linux-20200621092116 home]# mysql --version
[root@hecs-x-medium-2-linux-20200621092116 home]# service mysqld start
[root@hecs-x-medium-2-linux-20200621092116 home]# service mysqld status
第三步:重新设置密码,并开启远程连接
1、查看临时密码:得知临时密码
[root@hecs-x-medium-2-linux-20200621092116 home]# grep password /var/log/mysqld.log
2、使用临时密码登入并修改,并开启远程连接
[root@hecs-x-medium-2-linux-20200621092116 home]# mysql -uroot -p
mysql> set password = password("Mysql_123456");
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Mysql_123456' WITH GRANT OPTION;
3、开启服务器防火墙3306端口,安装完毕。
所有软件资源:百度网盘
提取码: u84t
常用命令:
关闭自启
systemctl disable mysqld
开启自启
systemctl enable mysqld
查看状态
systemctl status mysqld
启动
systemctl start mysqld
关闭
systemctl stop mysqld