美文网首页
3.docker安装mysql

3.docker安装mysql

作者: _zt_d58b | 来源:发表于2020-03-09 16:15 被阅读0次

    1.新建目录
    mkdir /data/mysql/config
    mkdir /data/mysql/data
    2.配置文件
    vim my.conf

    [mysqld]
    user=mysql
    character-set-server=utf8
    default_authentication_plugin=mysql_native_password
    log-bin=/var/lib/mysql/mysql-bin
    expire-logs-days=7
    max-binlog-size=500M
    server-id=1
    
    [client]
    default-character-set=utf8
    
    [mysql]
    default-character-set=utf8
    

    3.启动容器
    ···
    docker run -d -p 3306:3306 --restart always --privileged=true --name mysql -e MYSQL_ROOT_PASSWORD=123456 -v /data/mysql/config/my.conf:/etc/my.cnf -v=/data/mysql/data:/var/lib/mysql mysql:5.6

    ···

    4.修改登录
    ···
    docker exec -it mysql /bin/bash
    mysql -u root -p
    password: root
    进入mysql中运行一下命令
    use mysql;
    GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
    flush privileges;
    ···

    相关文章

      网友评论

          本文标题:3.docker安装mysql

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