首页 > 代码库 > docker mariadb镜像中文乱码

docker mariadb镜像中文乱码

  1. 从dockerhub上pull mariadb镜像

    docker pull mariadb

  2. 启动mariadb

    docker run --name mysql1 -e MYSQL_ROOT_PASSWORD=root -d mariadb

  3. 进入mariadb

    docker exec -it mysql1 /bin/bash

  4. 修改mariadb的配置文件

    文件所在目录:/etc/mysql/conf.d/mariadb.cnf

    修改内容:

     [client]
    # Default is Latin1, if you need UTF-8 set this (also in server section)
     default-character-set = utf8

    [mysqld]
    # Default is Latin1, if you need UTF-8 set all this (also in client section)
    character-set-server  = utf8

  5. 提交mysql容器,生成新的镜像,保存修改

    docker commit mysql1  mariadb:v1

docker mariadb镜像中文乱码