使用docker启动mysql

centos启动mysql

centos8里不需要安装mariadb-server

1.在宿主机上安装mariadb的客户端软件,获得mysql命令

yum  install  mariadb

2.启动mysql的容器

docker run --name sc-mysql-1 -e MYSQL_ROOT_PASSWORD='sc123456' -d -p 3306:3306  mysql:5.7.35

3.去访问(可以是其他的机器)

访问其他机器:mysql -h ip -uroot -p密码

-h 指定连接服务器的ip地址

注:若连不上,需要重启docker服务

  1.  
    [root@docker web]# mysql -h 192.168.0.17 -uroot -p123456
  2.  
     
  3.  
    Welcome to the MariaDB monitor.  Commands end with ; or \g.
  4.  
     
  5.  
    Your MySQL connection id is 2
  6.  
     
  7.  
    Server version: 5.7.35 MySQL Community Server (GPL)
  8.  
     
  9.  
     
  10.  
     
  11.  
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
  12.  
     
  13.  
     
  14.  
     
  15.  
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  16.  
     
  17.  
     
  18.  
     
  19.  
    MySQL [(none)]> show databases;  查看有哪些数据库
  20.  
     
  21.  
    +--------------------+
  22.  
     
  23.  
    | Database           |
  24.  
     
  25.  
    +--------------------+
  26.  
     
  27.  
    | information_schema |
  28.  
     
  29.  
    | mysql              |
  30.  
     
  31.  
    | performance_schema |
  32.  
     
  33.  
    | sys                |
  34.  
     
  35.  
    +--------------------+
  36.  
     
  37.  
    4 rows in set (0.002 sec)
  38.  
     
  39.  
     
  40.  
     
  41.  
    MySQL [(none)]> exit 退出
  42.  
     
  43.  
    Bye

 

文章链接: https://www.mfisp.com/15776.html

文章标题:使用docker启动mysql

文章版权:梦飞科技所发布的内容,部分为原创文章,转载请注明来源,网络转载文章如有侵权请联系我们!

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA打赏
共{{data.count}}人
人已打赏
建站教程投稿分享

Docker相比于传统虚拟化方式具有的优势和劣势

2023-1-18 20:45:43

建站教程投稿分享

Pyhon程序

2023-2-3 11:42:39

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
客户经理
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索

梦飞科技 - 最新云主机促销服务器租用优惠