赞
踩
1、查看原先系统是否安装mysql
rpm -qa | grep mysql
2、删除所有有关mysql文件
rpm -e 文件名
3、官方下载mysql安装包
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
4、安装mysql包
yum -y install mysql57-community-release-el7-10.noarch.rpm
5、安装mysql
yum -y install mysql-community-server
此时可能会报错如下:
Total size: 221 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.38-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
The GPG keys listed for the “MySQL 5.7 Community Server” repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.
Failing package is: mysql-community-common-5.7.38-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
解决办法:
修改/etc/yum.repos.d/目录下的mysql-community.repo文件,将里面所有的gpgcheck=1修改为gpgcheck=0即可。
6、启动mysql服务
systemctl start mysqld
7、查看服务状态
systemctl status mysqld
8、连接mysql
mysql -u root -p
输入密码root,此时连接不上修改密码步骤如下:
(1)修改mysql配置文件my.cnf,新增skip-grant-tables
(2)重启mysql
(3)连接mysql此时直接回车即可连接
(4)切换数据库
use mysql;切记不能少;
(5)修改密码
update mysql.user set authentication_string=password('新密码') where user='root';
(6)修改mysql连接端口号(根据自己需要可修改)
update mysql.user set host='要修改的端口号' where user='root';
(7)退出mysql
quit;
(8)修改mysql配置文件my.cnf,注释掉skip-grant-tables
(9)重启mysql密码修改完毕
9、连接mysql
mysql -u root -p
新密码
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。