wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
rpm -Uvh mysql57-community-release-el7-10.noarch.rpm
yum install -y mysql-community-server
Failing package is: mysql-community-server-5.7.37-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
原因:由于MySQL GPG 密钥已过期导致的
解决办法:以2022年为例
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
systemctl start mysqld.service
systemctl status mysqld.service
grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;
这时候我们就可以自己设置想要的密码了
ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
先退出mysql命令行,然后输入以下命令
systemctl enable mysqld
systemctl daemon-reload
vim /etc/my.cnf
改成如下,然后保存
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysql]
default-character-set=utf8
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
default-storage-engine=INNODB
character_set_server=utf8
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
service mysqld restart
firewall-cmd --state
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
一开始的时候我们安装的yum,每次yum操作都会更新一次,耗费时间,我们把他卸载掉
rpm -qa | grep mysql
yum -y remove mysql57-community-release-el7-10.noarch
(1)查看mysql是否启动:service mysqld status
启动mysql:service mysqld start
停止mysql:service mysqld stop
重启mysql:service mysqld restart
(2)查看临时密码:grep password /var/log/mysqld.log
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。