podman 安装mysql8 并开启不区分大小写

检查系统是否安装podman

c 复制代码
[root@mysql config]# cat /etc/redhat-release 
CentOS Linux release 8.5.2111
[root@mysql config]# 

[root@mysql config]# yum list installed | grep podman
[root@mysql config]# podman --version
-bash: /usr/bin/podman: No such file or directory
[root@mysql config]# yum repolist all
repo id               repo name                                                    status
AppStream             CentOS-8-stream - AppStream - mirrors.aliyun.com             enabled
PowerTools            CentOS-8-stream - PowerTools - mirrors.aliyun.com            disabled
base                  CentOS-8-stream - Base - mirrors.aliyun.com                  enabled
centosplus            CentOS-8-stream - Plus - mirrors.aliyun.com                  disabled
extras                CentOS-8-stream - Extras - mirrors.aliyun.com                enabled

开始安装podman

c 复制代码
[root@mysql config]# dnf install -y podman
Last metadata expiration check: 2:22:42 ago on Wed 12 Jul 2023 02:47:36 PM CST.
Dependencies resolved.
===========================================================================================
 Package                     Arch   Version                                Repo       Size
===========================================================================================
Installing:
 podman                      x86_64 3:4.5.1-5.module_el8+461+0c6b54ea      AppStream  15 M
Installing dependencies:
 conmon                      x86_64 3:2.1.7-1.module_el8+454+d7ef4b8d      AppStream  57 k
 container-selinux           noarch 2:2.218.0-1.module_el8+454+d7ef4b8d    AppStream  69 k
 containernetworking-plugins x86_64 1:1.3.0-2.module_el8+461+0c6b54ea      AppStream  21 M
 containers-common           x86_64 2:1-51.module_el8+454+d7ef4b8d         AppStream 136 k
 criu                        x86_64 3.18-4.module_el8+454+d7ef4b8d         AppStream 564 k
 fuse-overlayfs              x86_64 1.12-1.module_el8+454+d7ef4b8d         AppStream  70 k
 fuse3                       x86_64 3.2.1-12.el8                           base       50 k
 fuse3-libs                  x86_64 3.3.0-17.el8                           base       95 k
 libnet                      x86_64 1.1.6-15.el8                           AppStream  67 k
 libslirp                    x86_64 4.4.0-1.module_el8+454+d7ef4b8d        AppStream  70 k
 podman-catatonit            x86_64 3:4.5.1-5.module_el8+461+0c6b54ea      AppStream 360 k
 protobuf-c                  x86_64 1.3.0-8.el8                            AppStream  37 k
 runc                        x86_64 1:1.1.7-2.module_el8+463+b24391b1      AppStream 3.1 M
 shadow-utils-subid          x86_64 2:4.6-18.el8                           base      113 k
 slirp4netns                 x86_64 1.2.0-3.module_el8+454+d7ef4b8d        AppStream  54 k

Transaction Summary
===========================================================================================
Install  16 Packages

Total download size: 42 M
Installed size: 126 M
Downloading Packages:
(1/16): fuse3-libs-3.3.0-17.el8.x86_64.rpm                 325 kB/s |  95 kB     00:00    
(2/16): fuse3-3.2.1-12.el8.x86_64.rpm                      150 kB/s |  50 kB     00:00    
(3/16): shadow-utils-subid-4.6-18.el8.x86_64.rpm           283 kB/s | 113 kB     00:00    
(4/16): conmon-2.1.7-1.module_el8+454+d7ef4b8d.x86_64.rpm  314 kB/s |  57 kB     00:00    
(5/16): container-selinux-2.218.0-1.module_el8+454+d7ef4b8 314 kB/s |  69 kB     00:00    
(6/16): containers-common-1-51.module_el8+454+d7ef4b8d.x86 708 kB/s | 136 kB     00:00    
(7/16): fuse-overlayfs-1.12-1.module_el8+454+d7ef4b8d.x86_ 354 kB/s |  70 kB     00:00    
(8/16): libnet-1.1.6-15.el8.x86_64.rpm                     311 kB/s |  67 kB     00:00    
(9/16): criu-3.18-4.module_el8+454+d7ef4b8d.x86_64.rpm     856 kB/s | 564 kB     00:00    
(10/16): libslirp-4.4.0-1.module_el8+454+d7ef4b8d.x86_64.r 374 kB/s |  70 kB     00:00    
(11/16): podman-catatonit-4.5.1-5.module_el8+461+0c6b54ea. 739 kB/s | 360 kB     00:00    
(12/16): protobuf-c-1.3.0-8.el8.x86_64.rpm                 222 kB/s |  37 kB     00:00    
(13/16): runc-1.1.7-2.module_el8+463+b24391b1.x86_64.rpm   954 kB/s | 3.1 MB     00:03    
(14/16): slirp4netns-1.2.0-3.module_el8+454+d7ef4b8d.x86_6 356 kB/s |  54 kB     00:00    
(15/16): podman-4.5.1-5.module_el8+461+0c6b54ea.x86_64.rpm 977 kB/s |  15 MB     00:16    
^[[19~(16/16): containernetworki 95% [=======================- ] 1.3 MB/s |  40 MB     00:0(16/16): containernetworking-plugins-1.3.0-2.module_el8+46 933 kB/s |  21 MB     00:23    
-------------------------------------------------------------------------------------------
Total                                                      1.7 MB/s |  42 MB     00:23     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                   1/1 
  Running scriptlet: container-selinux-2:2.218.0-1.module_el8+454+d7ef4b8d.noarch     1/16 
  Installing       : container-selinux-2:2.218.0-1.module_el8+454+d7ef4b8d.noarch     1/16 
  Running scriptlet: container-selinux-2:2.218.0-1.module_el8+454+d7ef4b8d.noarch     1/16 
  Installing       : protobuf-c-1.3.0-8.el8.x86_64                                    2/16 
  Installing       : libslirp-4.4.0-1.module_el8+454+d7ef4b8d.x86_64                  3/16 
  Installing       : slirp4netns-1.2.0-3.module_el8+454+d7ef4b8d.x86_64               4/16 
  Installing       : libnet-1.1.6-15.el8.x86_64                                       5/16 
  Running scriptlet: libnet-1.1.6-15.el8.x86_64                                       5/16 
/sbin/ldconfig: /usr/lib64/llvm15/lib/libclang.so.15 is not a symbolic link


  Installing       : criu-3.18-4.module_el8+454+d7ef4b8d.x86_64                       6/16 
  Installing       : runc-1:1.1.7-2.module_el8+463+b24391b1.x86_64                    7/16 
  Installing       : containernetworking-plugins-1:1.3.0-2.module_el8+461+0c6b54ea    8/16 
  Installing       : conmon-3:2.1.7-1.module_el8+454+d7ef4b8d.x86_64                  9/16 
  Installing       : shadow-utils-subid-2:4.6-18.el8.x86_64                          10/16 
  Installing       : fuse3-libs-3.3.0-17.el8.x86_64                                  11/16 
  Running scriptlet: fuse3-libs-3.3.0-17.el8.x86_64                                  11/16 
/sbin/ldconfig: /usr/lib64/llvm15/lib/libclang.so.15 is not a symbolic link


  Installing       : fuse3-3.2.1-12.el8.x86_64                                       12/16 
  Installing       : fuse-overlayfs-1.12-1.module_el8+454+d7ef4b8d.x86_64            13/16 
  Running scriptlet: fuse-overlayfs-1.12-1.module_el8+454+d7ef4b8d.x86_64            13/16 
  Installing       : containers-common-2:1-51.module_el8+454+d7ef4b8d.x86_64         14/16 
  Installing       : podman-catatonit-3:4.5.1-5.module_el8+461+0c6b54ea.x86_64       15/16 
  Installing       : podman-3:4.5.1-5.module_el8+461+0c6b54ea.x86_64                 16/16 
  Running scriptlet: container-selinux-2:2.218.0-1.module_el8+454+d7ef4b8d.noarch    16/16 
  Running scriptlet: podman-3:4.5.1-5.module_el8+461+0c6b54ea.x86_64                 16/16 
/sbin/ldconfig: /usr/lib64/llvm15/lib/libclang.so.15 is not a symbolic link


[/usr/lib/tmpfiles.d/pesign.conf:1] Line references path below legacy directory /var/run/, updating /var/run/pesign → /run/pesign; please update the tmpfiles.d/ drop-in file accordingly.

  Verifying        : fuse3-3.2.1-12.el8.x86_64                                        1/16 
  Verifying        : fuse3-libs-3.3.0-17.el8.x86_64                                   2/16 
  Verifying        : shadow-utils-subid-2:4.6-18.el8.x86_64                           3/16 
  Verifying        : conmon-3:2.1.7-1.module_el8+454+d7ef4b8d.x86_64                  4/16 
  Verifying        : container-selinux-2:2.218.0-1.module_el8+454+d7ef4b8d.noarch     5/16 
  Verifying        : containernetworking-plugins-1:1.3.0-2.module_el8+461+0c6b54ea    6/16 
  Verifying        : containers-common-2:1-51.module_el8+454+d7ef4b8d.x86_64          7/16 
  Verifying        : criu-3.18-4.module_el8+454+d7ef4b8d.x86_64                       8/16 
  Verifying        : fuse-overlayfs-1.12-1.module_el8+454+d7ef4b8d.x86_64             9/16 
  Verifying        : libnet-1.1.6-15.el8.x86_64                                      10/16 
  Verifying        : libslirp-4.4.0-1.module_el8+454+d7ef4b8d.x86_64                 11/16 
  Verifying        : podman-3:4.5.1-5.module_el8+461+0c6b54ea.x86_64                 12/16 
  Verifying        : podman-catatonit-3:4.5.1-5.module_el8+461+0c6b54ea.x86_64       13/16 
  Verifying        : protobuf-c-1.3.0-8.el8.x86_64                                   14/16 
  Verifying        : runc-1:1.1.7-2.module_el8+463+b24391b1.x86_64                   15/16 
  Verifying        : slirp4netns-1.2.0-3.module_el8+454+d7ef4b8d.x86_64              16/16 

Installed:
  conmon-3:2.1.7-1.module_el8+454+d7ef4b8d.x86_64                                          
  container-selinux-2:2.218.0-1.module_el8+454+d7ef4b8d.noarch                             
  containernetworking-plugins-1:1.3.0-2.module_el8+461+0c6b54ea.x86_64                     
  containers-common-2:1-51.module_el8+454+d7ef4b8d.x86_64                                  
  criu-3.18-4.module_el8+454+d7ef4b8d.x86_64                                               
  fuse-overlayfs-1.12-1.module_el8+454+d7ef4b8d.x86_64                                     
  fuse3-3.2.1-12.el8.x86_64                                                                
  fuse3-libs-3.3.0-17.el8.x86_64                                                           
  libnet-1.1.6-15.el8.x86_64                                                               
  libslirp-4.4.0-1.module_el8+454+d7ef4b8d.x86_64                                          
  podman-3:4.5.1-5.module_el8+461+0c6b54ea.x86_64                                          
  podman-catatonit-3:4.5.1-5.module_el8+461+0c6b54ea.x86_64                                
  protobuf-c-1.3.0-8.el8.x86_64                                                            
  runc-1:1.1.7-2.module_el8+463+b24391b1.x86_64                                            
  shadow-utils-subid-2:4.6-18.el8.x86_64                                                   
  slirp4netns-1.2.0-3.module_el8+454+d7ef4b8d.x86_64                                       

Complete!
[root@mysql config]# ~

创建数据目录和配置文件

c 复制代码
[root@mysql config]# mkdir -p /usr/mysql/conf /usr/mysql/data
[root@mysql config]# chmod -R 755 /usr/mysql/

创建配置文件

c 复制代码
[root@mysql config]# vi /usr/mysql/conf/my.cnf
[root@mysql config]# cat /usr/mysql/conf/my.cnf 
[client]
#socket = /usr/mysql/mysqld.sock
default-character-set = utf8mb4

[mysqld]
#pid-file        = /var/run/mysqld/mysqld.pid
#socket          = /var/run/mysqld/mysqld.sock
#datadir         = /var/lib/mysql
#socket = /usr/mysql/mysqld.sock
#pid-file = /usr/mysql/mysqld.pid
lower_case_table_names=1
datadir = /usr/mysql/data
character_set_server = utf8mb4
collation_server = utf8mb4_bin
secure-file-priv= NULL
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Custom config should go here
!includedir /etc/mysql/conf.d/

下载指定版本mysql8.0.33

c 复制代码
[root@mysql config]# podman pull mysql:8.0.33
Resolved "mysql" as an alias (/var/cache/containers/short-name-aliases.conf)
Trying to pull docker.io/library/mysql:8.0.33...
Getting image source signatures
Copying blob 2e2c6bdc7a40 done  
Copying blob e2c03c89dcad done  
Copying blob 796892ddf5ac done  
Copying blob 68eb43837bf8 done  
Copying blob ebb53bc0dcca done  
Copying blob 6bca45eb31e1 done  
Copying blob 6f27b5c76970 done  
Copying blob 438533a24810 done  
Copying blob e5bdf19985e0 done  
Copying blob 667fa148337b done  
Copying blob 5baa702110e4 done  
Copying config 041315a161 done  
Writing manifest to image destination
Storing signatures
041315a161837f8bb87361e13390abda7159b98aeedee5e6152a0bb7a9b45f27

启动创建容器

c 复制代码
[root@mysql config]# podman run --restart=unless-stopped -d --name mysql -v /usr/mysql/conf/my.cnf:/etc/mysql/my.cnf -v /usr/mysql/data:/var/lib/mysql -p 3326:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:8.0.33
490b343aa47e2e22fa7b729f75ddef0c4d2c8fbcc19a0cc617debfc0b216f12d
[root@mysql config]# podman ps 
CONTAINER ID  IMAGE                           COMMAND     CREATED        STATUS        PORTS                   NAMES
490b343aa47e  docker.io/library/mysql:8.0.33  mysqld      7 seconds ago  Up 7 seconds  0.0.0.0:3326->3306/tcp  mysql
css 复制代码
参数说明

run run 是运行一个容器
-d  表示后台运行
-p  表示容器内部端口和服务器端口映射关联
--privileged=true 设值MySQL 的root用户权限, 否则外部不能使用root用户登陆。
忽略大小写:lower-case-table-names=2
-v /docker/mysql/conf/my.cnf:/etc/my.cnf 将服务器中的my.cnf配置映射到docker中的/docker/mysql/conf/my.cnf配置
-v /docker/mysql/data:/var/lib/mysql  同上,映射数据库的数据目录, 避免以后docker删除重新运行MySQL容器时数据丢失
-e MYSQL_ROOT_PASSWORD=_Admin123   设置MySQL数据库root用户的密码
--name mysql     设值容器名称为mysql mysql:8.0.16  表示从docker镜像mysql:8.0.16中启动一个容器
--character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci 设值数据库默认编码
------------------------------------------------
版权声明:本文为CSDN博主「躺平的菜鸟啊」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_43050077/article/details/118088582

修改mysql密码以及可访问主机

c 复制代码
[root@mysql config]# podman exec -it 490b343aa47e bash
bash-4.4# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.33 MySQL Community Server - GPL

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.

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql>  ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'master';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges
    -> ;
Query OK, 0 rows affected (0.01 sec)

mysql> ~
相关推荐
阿杰同学8 分钟前
如何实现 MySQL 的读写分离?
数据库·mysql
羊村懒哥22 分钟前
mysql-二进制安装方式
数据库·mysql
geovindu1 小时前
python: Oracle Stored Procedure query table
数据库·python·mysql·postgresql·oracle·sqlserver·mssql
小小小妮子~2 小时前
深入理解 MySQL 架构
数据库·mysql·架构
man20173 小时前
【2024最新】基于Python+Mysql+django的水果销售系统Lw+PPT
数据库·mysql·django
程序员-小李3 小时前
餐厅下单助手系统(Java+MySQL)
java·开发语言·mysql
hmbbpdx4 小时前
MySql B树 B+树
数据库·b树·mysql
冰镇毛衣4 小时前
4.5 数据表的外连接
数据库·sql·mysql
又蓝4 小时前
使用 Python 操作 MySQL 数据库的实用工具类:MySQLHandler
数据库·python·mysql
跨境商城搭建开发4 小时前
一个服务器可以搭建几个网站?搭建一个网站的流程介绍
运维·服务器·前端·vue.js·mysql·npm·php