問(wèn)題描述
-
服務(wù)器上安裝mysql時(shí)出現(xiàn)了報(bào)錯(cuò),簡(jiǎn)單記錄下解決方案
源 "MySQL 5.7 Community Server" 的 GPG 密鑰已安裝,但是不適用于此軟件包。請(qǐng)檢查源的公鑰 URL 是否配置正確。 失敗的軟件包是:mysql-community-client-5.7.40-1.el7.x86_64 GPG 密鑰配置為:file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
-
執(zhí)行:
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
[root@localhost mysql]# rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 [root@localhost mysql]# yum install mysql-server 已加載插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile 正在解決依賴關(guān)系 --> 正在檢查事務(wù) ---> 軟件包 mysql-community-server.x86_64.0.5.7.40-1.el7 將被 安裝 --> 正在處理依賴關(guān)系 mysql-community-common(x86-64) = 5.7.40-1.el7,它被軟件包 mysql-community-server-5.7.40-1.el7.x86_64 需要 --> 正在處理依賴關(guān)系 mysql-community-client(x86-64) >= 5.7.9,它被軟件包 mysql-community-server-5.7.40-1.el7.x86_64 需要 --> 正在檢查事務(wù) ---> 軟件包 mysql-community-client.x86_64.0.5.7.40-1.el7 將被 安裝 --> 正在處理依賴關(guān)系 mysql-community-libs(x86-64) >= 5.7.9,它被軟件包 mysql-community-client-5.7.40-1.el7.x86_64 需要 ---> 軟件包 mysql-community-common.x86_64.0.5.7.40-1.el7 將被 安裝 --> 正在檢查事務(wù) ---> 軟件包 mariadb-libs.x86_64.1.5.5.60-1.el7_5 將被 取代 --> 正在處理依賴關(guān)系 libmysqlclient.so.18()(64bit),它被軟件包 2:postfix-2.10.1-7.el7.x86_64 需要 --> 正在處理依賴關(guān)系 libmysqlclient.so.18(libmysqlclient_18)(64bit),它被軟件包 2:postfix-2.10.1-7.el7.x86_64 需要 ---> 軟件包 mysql-community-libs.x86_64.0.5.7.40-1.el7 將被 舍棄 --> 正在檢查事務(wù) ---> 軟件包 mysql-community-libs-compat.x86_64.0.5.7.40-1.el7 將被 舍棄 --> 解決依賴關(guān)系完成 依賴關(guān)系解決
-
啟動(dòng)mysql服務(wù)并查看運(yùn)行狀態(tài)
[root@localhost mysql]# service mysqld start Redirecting to /bin/systemctl start mysqld.service [root@localhost mysql]# systemctl status mysqld ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since 四 2022-10-13 05:42:37 UTC; 7s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 10239 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS) Process: 10181 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 10242 (mysqld) Tasks: 27 CGroup: /system.slice/mysqld.service └─10242 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid 10月 13 05:42:26 localhost.localdomain systemd[1]: Starting MySQL Server... 10月 13 05:42:37 localhost.localdomain systemd[1]: Started MySQL Server.
-
查看mysql初始密碼:
grep 'A temporary password' /var/log/mysqld.log
[root@localhost mysql]# grep 'A temporary password' /var/log/mysqld.log 2022-10-13T05:42:35.302480Z 1 [Note] A temporary password is generated for root@localhost: !oCdG%3prdP1
- 使用初始密碼進(jìn)行登錄,報(bào)錯(cuò):
ERROR 1045 (28000): Access denied for user 'root'@'localhost'
- 修改
/etc/my.cnf
文件,在最后加入skip-grant-tables
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html [mysqld] # # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid skip-grant-tables
- 使用初始密碼進(jìn)行登錄,報(bào)錯(cuò):
-
然后重啟數(shù)據(jù)庫(kù):systemctl restart mysqld
[root@localhost mysql]# systemctl restart mysqld
-
可以使用無(wú)密碼直接登錄:文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-535571.html
[root@localhost mysql]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.40 MySQL Community Server (GPL) 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>
-
修改root 密碼前,先刷新一下權(quán)限,然后再修改root密碼文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-535571.html
mysql> flush privileges; Query OK, 0 rows affected (0.01 sec) mysql> alter user 'root'@'localhost' identified by '123456'; Query OK, 0 rows affected (0.00 sec)
到了這里,關(guān)于已解決:源 “MySQL 5.7 Community Server“ 的 GPG 密鑰已安裝,但是不適用于此軟件包。請(qǐng)檢查源的公鑰 URL 是否配置正確 和 報(bào)錯(cuò):`ERROR 1045 (28000的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!