zoukankan      html  css  js  c++  java
  • 【Docker】mysq的容器化安装及使用

    mysq的容器化安装及使用###

    ①查找镜像并获取指定镜像版本

    docker search mysql
    docker pull mysql:5.6 
    

    ②运行容器

    docker run -d -p 3306:3306 -v /etc/mysql:/etc/mysql --name mysql  -e MYSQL_ROOT_PASSWORD=123456 mysql:5.6
    

    ③连接数据库

    [root@izuf6hcb8yumasfp52oemxz ~]# docker exec -it e7906d560a7a /bin/sh
    # mysql -uroot -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    

    4⃣️操作数据库

    mysql> SHOW DATABASES;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    4 rows in set (0.16 sec)
    
    mysql> CREATE DATABASE library;
    Query OK, 1 row affected (0.22 sec)
    
    mysql> use library;
    Database changed
    
    mysql> CREATE TABLE tb_emp1
        ->     (
        ->      id INT(11),
        ->      name VARCHAR(25),
        ->      deptId INT(11),
        ->      salary FLOAT
        ->      );
    Query OK, 0 rows affected (0.29 sec)
    
    mysql> show tables;
    +-------------------+
    | Tables_in_library |
    +-------------------+
    | tb_emp1           |
    +-------------------+
    1 row in set (0.14 sec)
    
    

    附上客户端连接数据库工具:Navicat Premium连接数据库显示表截图:

  • 相关阅读:
    day3-python之函数进阶(三)
    day3-python之函数初识(二)
    day3-python之文件操作(一)
    tomcat
    集群
    nginx
    nginx--zabbix监控status waiting
    zabbix监控之mysql主从状态&mysql主从延迟
    zabbix监控之进程&日志监控
    zabbix监控流程(监控linux上某个文件是否有改动)
  • 原文地址:https://www.cnblogs.com/wucaiyun1/p/12318901.html
Copyright © 2011-2022 走看看