Yum安装mysql5.7

11 篇文章 0 订阅

Step1: 检测系统是否自带安装mysql
# yum list installed | grep mysql

Step2: 删除系统自带的mysql及其依赖
命令:
# yum -y remove mysql-libs.x86_64

Step3: 给CentOS添加rpm源,并且选择较新的源
命令:
# wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
# centos7版本 自己修改下yum源 wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
# 若已有对应版本的rpm文件则直接放到当前目录即可,跳过localinstall步骤
# yum localinstall mysql-community-release-el6-5.noarch.rpm #根据wget下载的rpm决定localinstall的rpm
# yum repolist all | grep mysql
# yum install yum-utils -y
# yum-config-manager --disable mysql55-community
# yum-config-manager --disable mysql56-community
# yum-config-manager --enable mysql57-community-dmr
# yum repolist enabled | grep mysql

Step4:安装mysql 服务器
命令:
# 安装太慢的话 参考 https://www.cnblogs.com/damofeisha/p/10962856.html
# yum install mysql-community-server 

Step5: 启动mysql
命令:
# service mysqld start

Step6: 查看mysql是否自启动,并且设置开启自启动
命令:
# chkconfig --list | grep mysqld
# chkconfig mysqld on
查看默认密码并登录
# grep 'temporary password' /var/log/mysqld.log
 
# 登陆mysql
# mysql -uroot -p #之后输入上面查到的密码
# set global validate_password_policy=0; 
# set global validate_password_length=1;
# SET PASSWORD = PASSWORD('123456'); 修改默认密码

Step7: mysql安全设置
命令:
# mysql_secure_installation

参考相关文档地址: 
http://www.rackspace.com/know...
http://dev.mysql.com/doc/refm...
http://www.cnblogs.com/xiaolu...
 
#忘记密码 修改密码
my.cnf的【mysqld】节点下添加配置skip-grant-tables
#登录mysql
mysql  or 【其他机器】 mysql -hxxxxxx
update mysql.user set authentication_string=password('123456') where user='root' ;
flush privileges

常见问题

1、yum install速度太慢

原因是科学网络,参考 https://www.cnblogs.com/damofeisha/p/10962856.html,自己下载对应源即可

2、Public key for mysql-community-client-5.7.38-1.el7.x86_64.rpm is not installed

原因是Mysql的GPG升级了,需要重新获取

运行 rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值