一. 安装过程中的公钥未安装错误

安装命令:

wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
cd /etc/yum.repos.d/
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
yum install mysql-server

错误信息:

mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm 的公钥尚未安装


 失败的软件包是:mysql-community-libs-compat-5.7.37-1.el7.x86_64
 GPG  密钥配置为:file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

解决办法:

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

再次安装,成功

yum install mysql-server

二. 设置root 登录密码为空

启动mysql服务端mysqld后,因为没有配置root及密码,启动mysql客户端会出错

systemctl restart mysqld
mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

设置免密登录

vi /etc/my.cnf
#添加跳过密码验证
skip-grant-tables

重启mysql服务

systemctl restart mysqld

设置root登录密码为空

mysql -uroot
mysql> use mysql
mysql> update user set authentication_string='' where user='root';
mysql> quit

关闭免密登录

vi /etc/my.cnf
#注释掉跳过密码验证
#skip-grant-tables

重启mysql服务

systemctl restart mysqld

登录mysql客户端不需要密码, 出现提示输入密码时直接回车:

mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.37

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐