运行 mysql
# 2019-01-07 修改: mysql 修改成 mariadb
docker run -itd --name mysql-test -e MYSQL_ROOT_PASSWORD=123456 mariadb # 如果需要docker外的程序连接,则暴露端口: docker run -itd --name mysql-test -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 mariadb # 如果需要把数据保存在外面: docker run -itd --name mysql-test -v /local/dir:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 mariadb
运行 phpmyadmin
docker run -itd --name phpmyadmin --link mysql-test:db -p 8080:80 phpmyadmin/phpmyadmin
# 2019-03-22 增加:
使用 docker-compose 方式运行
version: "3" services: db: image: mariadb volumes: - ./data:/var/lib/mysql ports: - "3306:3306" environment: - MYSQL_ROOT_PASSWORD=123456 phpmyadmin: image: phpmyadmin/phpmyadmin ports: - "8080:80" links: - db
# 2019-10-30 修改: 使用 adminer 代替 phpmyadmin
version: "3.7" services: db: image: mariadb restart: always volumes: - db_data:/var/lib/mysql ports: - "3306:3306" environment: # default user name: root - MYSQL_ROOT_PASSWORD=123456 #- TZ=Asia/Shanghai adminer: image: adminer restart: always ports: - "8080:8080" # phpmyadmin: # image: phpmyadmin/phpmyadmin # restart: always # ports: # - "8080:80" # links: # - db volumes: db_data: