docker-compose起来一个mysql容器并创建数据库和授权

1. docker-compose.yml

version: '2'
services:
  mysql56:
    image: mysql:5.6
    container_name: mysql56
    restart: always
    working_dir: /opt/syncd-deploy
    environment:
      MYSQL_ROOT_PASSWORD: 123456
    volumes:
      - ./database:/var/lib/mysql
    ports:
      - 3306:3306

2. 进入mysql创建数据库并授权

mysql -uroot -p
> create database youdbname default charset 'utf8';
> grant all on youdbname.* to 'yourname'@'192%' identified by 'weakPassword';
> flush privileges;
> quit

你可能感兴趣的:(docker-compose起来一个mysql容器并创建数据库和授权)