首页 > 数据库 >podman 安装 MySQL8

podman 安装 MySQL8

时间:2022-12-04 17:47:14浏览次数:46  
标签:MySQL8 root podman blob Copying mysql var pod 安装

如何在测试环境下,快速创建一个MySQL环境呢?容器化是个不错的选择。

  • 拉取MySQL镜像
[root@node11 ~]# podman pull mysql
✔ docker.io/library/mysql:latest
Trying to pull docker.io/library/mysql:latest...
Getting image source signatures
Copying blob 996f1bba14d6 skipped: already exists  
Copying blob a4355e2c82df skipped: already exists  
Copying blob a9d7aedb7ad7 skipped: already exists  
Copying blob 26e144df551b done  
Copying blob 9878df6a0cc3 done  
Copying blob e0859d5816ee done  
Copying blob da8c1ec8ff26 done  
Copying blob ea8748759282 done  
Copying blob 24ee75d8667d done  
Copying blob b43b187428e3 done  
Copying blob 202e454031c6 done  
Copying config a3a2968869 done  
Writing manifest to image destination
Storing signatures
a3a2968869cf080dbbd2adaac9e4075cc358b50a1451ff5e2b9ae90551a4735f

  • 创建文件目录
[root@node11 ~]#  mkdir -p ~/pod/mysql/conf
[root@node11 ~]#  mkdir -p ~/pod/mysql/log 
[root@node11 ~]#  mkdir -p ~/pod/mysql/data

  • 设置配置文件
[root@node11 ~]# vim ~/pod/mysql/conf/my.cnf
[mysqld]
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
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/

default_authentication_plugin= mysql_native_password

  • 启动容器
podman run \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=root \
-v ~/pod/mysql/data:/var/lib/mysql:rw \
-v ~/pod/mysql/log:/var/log/mysql:rw \
-v ~/pod/mysql/conf/my.cnf:/etc/mysql/my.cnf:rw \
-v /etc/localtime:/etc/localtime:ro \
--name mysql \
--network bridge \
--privileged=true \ # <--<---- 注意这个配置如果没有关闭 selinux的时候必须添加,不然启动mysql容器时报权限问题
-d mysql 
  • 进入MySQL容器,并设置root密码
[root@node11 pod]#  podman exec -it mysql /bin/bash
bash-4.4# mysql -u root -p
mysql: [Warning] World-writable config file '/etc/mysql/my.cnf' is ignored.
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.31 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)
mysql> alter user 'root'@'%' identified with mysql_native_password by '123456';
Query OK, 0 rows affected (0.00 sec)

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


下面是没有设置 --privileged=true 启动容器出错的情况,如果这种情况下,可以关闭selinux 或者 设置--privileged=true 来解决。

[root@node11 ~]#  podman run \
>     -p 3306:3306 \
>     -e MYSQL_ROOT_PASSWORD=root \
>     -v ~/pod/mysql/data:/var/lib/mysql:rw \
>     -v ~/pod/mysql/log:/var/log/mysql:rw \
>     -v ~/pod/mysql/conf/my.cnf:/etc/mysql/my.cnf:rw \
>     -v /etc/localtime:/etc/localtime:ro \
>     --name mysql \
>     --network bridge \
>     -d mysql

[root@node11 pod]# podman logs 421ff0acfc66
2022-12-04 00:51:17-08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.31-1.el8 started.
find: '/var/lib/mysql/': Permission denied
find: '/var/lib/mysql': Permission denied
chown: changing ownership of '/var/lib/mysql/': Permission denied
chown: changing ownership of '/var/lib/mysql': Permission denied

标签:MySQL8,root,podman,blob,Copying,mysql,var,pod,安装
From: https://www.cnblogs.com/yuedu/p/16950263.html

相关文章

  • deepin国产操作系统 nvidia-docker2 的安装
       ======================================  平时偶尔使用deepin系统,突然有个 nvidia-docker的程序需要运行,平时工作都是在用Ubuntu,所以对deepin安装docker......
  • Linux使用 RPM 安装 Logstash
    参考网站:https://www.elastic.co/guide/en/logstash/8.5/installing-logstash.html#_yum1.下载并安装公共签名密钥rpm--importhttps://artifacts.elastic.co/GPG-KEY-......
  • OEL 5.11安装oracle 10.2.0.1
    文档课题:OEL5.11安装oracle10.2.0.1系统:oel5.1164位数据库:oracle10.2.0.164位软件包名称:10201_database_linux_x86_64.cpio.gz1、安装准备1.1、系统信息[root@leo-10g......
  • 解决CentOS 7 最小化安装后无ifconfig命令
    需求:在我们给服务器安装新系统后(centos7),由于是最小化安装,许多工具包并没有安装上,而是需要自己手动去安装,ifconfig这条命令就是需要手动安装。ifconfig是我们平时查看IP地......
  • go环境搭建及tjfoc-gm安装
    go环境搭建及tjfoc-gm安装一、环境配置1首先进入usr/local文件夹,下载go语言环境配置压缩包wgethttps://dl.google.com/go/go1.19.3.linux-amd64.tar.gz2配置......
  • 安装WSL2 (以Ubuntu的安装为例)
    使用wsl2原因:内存开销比vm小很多,启动还很快进入微软自带应用商店下载ubuntu,完成后打开,设置账户。因为默认是安装在C盘中的,如果想要迁移位置,打开cmd,执行以下命令#查......
  • win10安装wsl1的ubuntu18.04
    1.需求主系统:win10子系统:ubuntu18.04,要求wsl1,并且系统默认登录账户为没有密码的root根账户2.步骤(1)启用“适用于Linux的Windows子系统”可选功能在Windows中修改......
  • Kubeadm高可用安装k8s集群-补充说明
    1.1k8s1.24管理用户无token处理1.24版本及以上关闭了自动生成admin-user-token的配置[root@k8s-master01dashboard]#kubectl-nkube-systemgetsecret|grepadmi......
  • Linux使用 RPM 安装 Elasticsearch
    参考网站:https://www.elastic.co/guide/en/elasticsearch/reference/8.5/rpm.html#rpm-repo1.导入ElasticsearchGPG签名密钥rpm--importhttps://artifacts.elastic.c......
  • elasticsearch安装以及注意事项
    一、修改linux限制1./etc/security/limits.conf#1.修改系统中允许应用最多创建多少文件等的限制权限。一般限制应用最多创建的文件为65535,但是es至少需要65536的文件创建权......