zoukankan      html  css  js  c++  java
  • Docker搭建MySQL数据库

    1、docker 可以执行如下命令一步搭建MySQL数据库:

    docker run --name mysql -v $PWD/mysql:/var/lib/mysql -p3306:3308 -eMYSQL_ROOT_PASSWORD=123456 -d mysql:5.7

    命令中显示我们使用的是Docker技术并创建一个名字为mysql的容器,然后在容器中把数据关联到本地的MySQL,并把MySQL的3306接口映射到外面的3308,同时为用户设置一个账户密码

    2、进入镜像

    docker exec -it mysql bash

    3、连接mysql

    执行命令: mysql -h127.0.0.1 -p
    root@706629fa5ef0:/# mysql -h127.0.0.1 -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 3
    Server version: 5.7.29 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql>

    查看数据库:

    mysql> show databases;
    +--------------------+
    | Database |
    +--------------------+
    | information_schema |
    | mysql |
    | performance_schema |
    | sys |
    +--------------------+
    4 rows in set (0.01 sec)

  • 相关阅读:
    C#中关于DBNULL的处理方法
    html 点击复制
    AJAX的简洁写法
    PHP 数组模糊查询
    PHP二维数组搜索返回数组
    php 数组排序得方法
    PHPExcel的使用
    使用PHPword中文乱码并且下载的方法
    关于多图上传的修改的操作
    把一个表里的两列或者三列合并为一行
  • 原文地址:https://www.cnblogs.com/mingfan/p/12697511.html
Copyright © 2011-2022 走看看