美文网首页
podman安装mysql

podman安装mysql

作者: MNBVCXZASDFG | 来源:发表于2022-02-14 19:30 被阅读0次

1.podman安装mysql8

   podman pull mysql

2. 安装

以挂载的方式进行安装

    mkdir -p ~/pod/mysql/conf    # 配置文件  
    mkdir -p ~/pod/mysql/log     # 日志文件 
    mkdir -p ~/pod/mysql/data   #数据存放

在~/pod/mysql/conf中添加my.cnf配置文件,如下

   # Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

#
# The MySQL  Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[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 my-bridge \
    -d mysql

设置远程登录
运行

   podman exec -it mysql /bin/bash

在命令行当中,进行数据库系统中:

    mysql -u root -p

输入密码进入
运行以下命令

 alter user 'root'@'%' identified with mysql_native_password by '密码';

即可远程登录

ps:ubuntu 推荐一个容器管理插件
https://extensions.gnome.org/ 搜索podman,会有一个Containers的插件,安装成功后,即可看到已运行的容器

相关文章

网友评论

      本文标题:podman安装mysql

      本文链接:https://www.haomeiwen.com/subject/uvdhlrtx.html