zoukankan      html  css  js  c++  java
  • 国产系统安装docker-ce、配置mysql

    银河麒麟安装docker

    一、安装

    添加用户组和用户,非root启动docker

    groupadd docker
    useradd -m -g docker docker -s /sbin/nologin
    

    添加权限

    sudo tee /etc/sudoers.d/docker >/dev/null <<EOF
    docker ALL=(ALL)        NOPASSWD:  ALL
    EOF
    

    安装

    cd ~
    wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.6.tgz
    tar xzvf  docker-20.10.6.tgz
    cp docker/* /usr/bin/
    rm docker-20.10.6.tgz -rf
    rm docker -rf
    

    二、配置docker启动

    sudo tee /usr/lib/systemd/system/dockerd.service >/dev/null <<EOF
    [Unit]
    Description=Docker Daemon Service
    
    [Service]
    ExecStart=sudo /usr/bin/dockerd
    Restart=always
    RestartSec=10
    KillSignal=SIGINT
    SyslogIdentifier=docker daemon
    User=docker
    Group=docker
    [Install]
    WantedBy=multi-user.target
    EOF
    

    三、配置docker镜像源

    mkdir /etc/docker
    tee /etc/docker/daemon.json >/dev/null <<EOF
    {
     "registry-mirrors": ["http://hub-mirror.c.163.com"]
    }
    EOF
    

    四、启动docker

    systemctl enable dockerd
    systemctl start dockerd
    

    五、安装mysql

    1.文件解析

    /home/mysql/conf.d/docker.cnf 此文件默认为 [mysqld] 组,监听端口等配置在此。
    /home/mysql/conf.d/mysql.cnf 此文件为客户端配置,配置组为[mysql]。

    2.命令行

    mkdir -p /home/mysql/conf.d
    tee /home/mysql/conf.d/docker.cnf >/dev/null <<EOF
    [mysqld]
    skip-host-cache
    skip-name-resolve
    bind-address = 0.0.0.0
    port = 3306
    character-set-client-handshake = false
    character-set-server = utf8mb4
    init_connect='SET NAMES utf8mb4'
    EOF
    
    tee /home/mysql/conf.d/mysql.cnf >/dev/null <<EOF
    [client]
    default-character-set = utf8mb4
    
    [mysql]
    default-character-set = utf8mb4
    EOF
    

    运行 mysql

    默认将配置文件放在 /home/mysql/conf.d
    否则将 /home/mysql/database

    docker run 
    --name mysql 
    -d 
    -p 3306:3306 
    -v /home/mysql/conf.d:/etc/mysql/conf.d 
    -v /home/mysql/database:/var/lib/mysql 
    -e MYSQL_ROOT_PASSWORD=mysql 
    -e MYSQL_USER=mysql 
    -e MYSQL_PASSWORD=mysql 
    mysql:8.0.25
    

    更改密码

    ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root'
    FLUSH PRIVILEGES;
    
  • 相关阅读:
    清除某个数据库的所有数据库连接的存储过程
    IIS的Windows集成身份验证总结
    新项目的页面不要直接从PageBase继承
    安装Win2003 SP1遇到拒绝访问
    ASP.NET2.0站点跨服务器访问Sql Sever 2005 Reporting Service
    当CodeSmith不在时,续……
    Web讯雷导致IIS无法启动的问题
    Intro to eDiscovery in SharePoint, Exchange, and Lync 2013
    微软云平台
    团队开发博客
  • 原文地址:https://www.cnblogs.com/yeqifeng2288/p/14839136.html
Copyright © 2011-2022 走看看