1. 程式人生 > >Docker之Mysql5.7安裝

Docker之Mysql5.7安裝

mkdir data/mysql/logs data/mysql/conf data/mysql/data -p
docker pull mysql/mysql-server:5.7

docker run 
    --name mysql-server5.7 
    --restart always 
    -d -p 3306:3306 
    -v /root/data/mysql/data:/var/lib/mysql 
    -v /root/data/mysql/conf/my.cnf:/etc/mysql/my.cnf
    -v /root/data/mysql/logs:/logs 
    -e MYSQL_ROOT_PASSWORD=root123456 
    -e MYSQL_USER=reus
    -e MYSQL_PASSWORD=123456
    mysql/mysql-server:5.7 
    --character-set-server=utf8 
    --collation-server=utf8_general_ci


docker exec -it 容器名稱 bash

grant all privileges on *.* to 'reus'@'%' identified by '密碼' with grant option;
flush privileges;
#my.cnf

    [client]
    default-character-set=utf8
    
    [mysql]
    default-character-set=utf8
    
    [mysqld]
    init_connect='SET collation_connection = utf8_unicode_ci'
    init_connect='SET NAMES utf8'
    character-set-server=utf8
    collation-server=utf8_unicode_ci
    skip-character-set-client-handshake