docker安装mysql5.6

  1. 执行命令安装mysql

    docker run -d --privileged=true \
    --restart=always \
    --name mysql \
    -v /usr/local/mysql/data:/var/lib/mysql \
    -v /usr/local/mysql/conf:/etc/mysql \
    -v /usr/local/mysql/log:/var/log/mysql \
    -p 8306:3306 \
    -e TZ=Asia/Shanghai \
    -e MYSQL_ROOT_PASSWORD=123456 \
    mysql:5.6 \
    --character-set-server=utf8mb4 \
    --collation-server=utf8mb4_general_ci
    安装mysql5.7会报错
  2. 进入mysql容器,登录mysql

    docker exec -it mysql bash
    mysql -u root -p 123456
  3. 修改root密码,并允许远程登录

    set password for [email protected] = password('新密码');
    set password for [email protected]'%' = password('新密码');
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '新密码' WITH GRANT OPTION;
    安装完毕
作者:李博帅 原文地址:https://segmentfault.com/a/1190000042519286

%s 个评论

要回复文章请先登录注册