当前位置: 首页 > article >正文

亲测openEuler 22.03 LTS 安装MySQL 5.7和注意事项

1、添加 MySQL 5.7 的软件源:

[root@vm ~]# dnf install https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
OS                                                                                        15 kB/s | 2.3 kB     00:00    
everything                                                                                16 kB/s | 2.3 kB     00:00    
EPOL                                                                                      16 kB/s | 2.3 kB     00:00    
debuginfo                                                                                 16 kB/s | 2.3 kB     00:00    
source                                                                                    15 kB/s | 2.3 kB     00:00    
update                                                                                    16 kB/s | 2.3 kB     00:00    
update-source                                                                             15 kB/s | 2.3 kB     00:00    
mysql57-community-release-el7-11.noarch.rpm                                              9.3 kB/s |  25 kB     00:02    
Dependencies resolved.
=========================================================================================================================
 Package                                  Architecture          Version                Repository                   Size
=========================================================================================================================
Installing:
 mysql57-community-release                noarch                el7-11                 @commandline                 25 k

Transaction Summary
=========================================================================================================================
Install  1 Package

Total size: 25 k
Installed size: 31 k
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                 1/1 
  Installing       : mysql57-community-release-el7-11.noarch                                                         1/1 
  Verifying        : mysql57-community-release-el7-11.noarch                                                         1/1 

Installed:
  mysql57-community-release-el7-11.noarch                                                                                

Complete!

[root@vm ~]# 

2、导入MySQL仓库的公钥 和 检查已安装的GPG公钥

[root@vm ~]# rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql
[root@vm ~]# rpm -qa gpg-pubkey*
gpg-pubkey-5072e1f5-5c4058fb
gpg-pubkey-b675600b-63913a47

3、安装MySQL 5.7

这里注意事项,重点是要 -y --nogpgcheck 禁用GPG检查 ,不然会报错 “Error: GPG check FAILED”安装不成功。

[root@vm ~]# dnf install mysql-community-server -y --nogpgcheck
Last metadata expiration check: 0:09:32 ago on 2024-09-19T17:35:48 CST.
Dependencies resolved.
=========================================================================================================================
 Package                            Architecture       Version                       Repository                     Size
=========================================================================================================================
Installing:
 mysql-community-server             x86_64             5.7.44-1.el7                  mysql57-community             184 M
Installing dependencies:
 mysql-community-client             x86_64             5.7.44-1.el7                  mysql57-community              31 M
 mysql-community-common             x86_64             5.7.44-1.el7                  mysql57-community             313 k
 mysql-community-libs               x86_64             5.7.44-1.el7                  mysql57-community             3.0 M
 ncurses-compat-libs                x86_64             6.3-12.oe2203sp2              update                        284 k

Transaction Summary
=========================================================================================================================
Install  5 Packages

Total size: 219 M
Installed size: 931 M
Downloading Packages:
[SKIPPED] mysql-community-client-5.7.44-1.el7.x86_64.rpm: Already downloaded                                            
[SKIPPED] mysql-community-common-5.7.44-1.el7.x86_64.rpm: Already downloaded                                            
[SKIPPED] mysql-community-libs-5.7.44-1.el7.x86_64.rpm: Already downloaded                                              
[SKIPPED] mysql-community-server-5.7.44-1.el7.x86_64.rpm: Already downloaded                                            
[SKIPPED] ncurses-compat-libs-6.3-12.oe2203sp2.x86_64.rpm: Already downloaded                                           
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                 1/1 
  Installing       : mysql-community-common-5.7.44-1.el7.x86_64                                                      1/5 
  Installing       : mysql-community-libs-5.7.44-1.el7.x86_64                                                        2/5 
  Running scriptlet: mysql-community-libs-5.7.44-1.el7.x86_64                                                        2/5 
  Installing       : ncurses-compat-libs-6.3-12.oe2203sp2.x86_64                                                     3/5 
  Installing       : mysql-community-client-5.7.44-1.el7.x86_64                                                      4/5 
  Running scriptlet: mysql-community-server-5.7.44-1.el7.x86_64                                                      5/5 
  Installing       : mysql-community-server-5.7.44-1.el7.x86_64                                                      5/5 
  Running scriptlet: mysql-community-server-5.7.44-1.el7.x86_64                                                      5/5 
/usr/lib/tmpfiles.d/mysql.conf:23: Line references path below legacy directory /var/run/, updating /var/run/mysqld → /run/mysqld; please update the tmpfiles.d/ drop-in file accordingly.

  Verifying        : mysql-community-client-5.7.44-1.el7.x86_64                                                      1/5 
  Verifying        : mysql-community-common-5.7.44-1.el7.x86_64                                                      2/5 
  Verifying        : mysql-community-libs-5.7.44-1.el7.x86_64                                                        3/5 
  Verifying        : mysql-community-server-5.7.44-1.el7.x86_64                                                      4/5 
  Verifying        : ncurses-compat-libs-6.3-12.oe2203sp2.x86_64                                                     5/5 

Installed:
  mysql-community-client-5.7.44-1.el7.x86_64                  mysql-community-common-5.7.44-1.el7.x86_64                
  mysql-community-libs-5.7.44-1.el7.x86_64                    mysql-community-server-5.7.44-1.el7.x86_64                
  ncurses-compat-libs-6.3-12.oe2203sp2.x86_64                

Complete!

4、启动MySQL服务

[root@vm ~]# systemctl start mysqld

5、(可选)检查MySQL服务

看到绿色的**active (running)**即表示服务正常

[root@vm ~]# systemctl status mysqld
● mysqld.service - MySQL Server
     Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
     Active: active (running) since Thu 2024-09-19 17:51:17 CST; 29min ago
       Docs: man:mysqld(8)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
    Process: 21829 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
    Process: 21897 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exite>
   Main PID: 21899 (mysqld)
      Tasks: 28 (limit: 49004)
     Memory: 335.3M
     CGroup: /system.slice/mysqld.service
             └─ 21899 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Sep 19 17:51:05 vm systemd[1]: Starting MySQL Server...
Sep 19 17:51:12 vm mysqld_pre_systemd[21868]: mysqld: Out of memory (Needed 4294967200 bytes)
Sep 19 17:51:17 vm systemd[1]: Started MySQL Server.

[root@vm ~]#

6.查询MySQL生成的随机密码

如下【ty#X(:&II9lz】部分是密码

[root@vm ~]# grep 'temporary password' /var/log/mysqld.log
2024-09-19T09:51:14.136274Z 1 [Note] A temporary password is generated for root@localhost: ty#X(:&II9lz

7.用随机密码登陆MySQL

使用随机【ty#X(:&II9lz】密码登陆

[root@vm ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 25
Server version: 5.7.44

Copyright (c) 2000, 2023, 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.

8.修改密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
Query OK, 0 rows affected (0.00 sec)

mysql> exit;
Bye
[root@vm ~]# 

new_password替换为你想要设置的新密码;
‘localhost’ 改为 ‘%’ 代表任何主机,root用户将能够从任何远程机器连接到MySQL服务器。

🌸🌸完结散花🌸🌸


http://www.kler.cn/news/312159.html

相关文章:

  • Spring 源码解读:实现自定义注解处理器
  • Linux文件IO(二)-文件操作使用详解
  • 论文解读《COMMA: Co-articulated Multi-Modal Learning》
  • mysql 重置密码
  • 部署Prometheus+Grafana批量监控Linux服务器
  • Django框架全面指南
  • 如何解决“json schema validation error ”错误? -- HarmonyOS自学6
  • 鸿蒙环境服务端签名直传文件到OSS
  • HTTP协议详解以及常见的状态码
  • 设计模式之外观设计模式
  • Ubuntu24.04部署docker
  • VD2811A SOP-8封装 可直接替代XB8886G芯片 大电流充放电锂保芯片
  • 智能机巢+无人机:自动化巡检技术详解
  • qt char*与QString互转
  • 巧用联合与枚举:解锁自定义类型的无限潜力
  • 【深度学习|PyTorch】基于 PyTorch 搭建 U-Net 深度学习语义分割模型——附代码及其解释!
  • 【HTTP】方法(method)以及 GET 和 POST 的区别
  • 控制浏览器显示隐藏c++
  • MySQL 主从复制部署与优化
  • 部署k8s基础环境
  • Java Web实战:利用三层架构与Servlet构建登录注册模块
  • 828华为云征文 | 云服务器Flexus X实例:部署 AgentOps,全方位监测智能体
  • Find My资讯|AirPods 4标准版充电盒无扬声器,Find My查找不会发出声音
  • Vue3:编写一个插件(进阶)
  • neuroph建立简单BP网络
  • windows消息机制
  • Spring Boot 项目中整合 RabbitMQ,使用死信队列(Dead Letter Exchange, DLX)实现延迟队列功能
  • 设计模式 组合模式(Composite Pattern)
  • 【HTTP】认识 URL 和 URL encode
  • KL散度(Kullback-Leibler)