国产数据库实战之Docker部署MyWebSQL数据库管理工具

一、MyWebSQL介绍

1.MyWebSQL简介

MyWebSql 是一个基于Web的MySQL/Postgres数据库管理客户端,除了操作表格数据外,还可以对包括视图,存储过程,触发器和函数在内的对象进行控制。支持数据和查询结果的导入导出,还内置一个带语法着色功能的SQL编辑器。

2.MyWebSQL特点

  1. 快速,直观,开发人员友好的用户界面。

  2. 兼容所有主要的网络浏览器。

  3. 创建/编辑表结构,无需编写查询。

  4. WYSIWYG编辑数据库表和查询数据。

  5. 同时编辑和删除多个记录极其轻松。

  6. 语法突出显示富文本sql编辑器内部的浏览器,无需任何插件。

  7. 将完整的数据库/表/查询结果导出到外部文件。 

  8. 在不学习单个命令的情况下使用MySQL相关工具。 

  9. 顺滑的界面,支持多种主题。

  10. 在几乎所有主要服务器配置上易于部署和安装。

二、检查本地环境

1.检查Docker状态

[root@node config]# systemctl status docker |grep active    Active: active (running) since Fri 2022-10-14 14:06:47 CST; 57min ago 

2.检查docker-compose版本

[root@node config]# docker-compose version docker-compose version 1.25.0, build 0a186604 docker-py version: 4.1.0 CPython version: 3.7.4 OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019  

三、下载MyWebSQL镜像

[root@node mywebsql]# docker pull rizo928/mywebsql-flex Using default tag: latest latest: Pulling from rizo928/mywebsql-flex 7dcf5a444392: Pull complete  759aa75f3cee: Pull complete  3fa871dc8a2b: Pull complete  224c42ae46e7: Pull complete  9e4d7c038c3d: Pull complete  2bef889cbb8f: Pull complete  be57bc4687e5: Pull complete  60c801568b81: Pull complete  8c2e7907f75b: Pull complete  0b1b15dd6a1b: Pull complete  23d29f4252f8: Pull complete  d687c5477ed5: Pull complete  2941b08edd24: Pull complete  3b4a514b0015: Pull complete  9bafa9902ec3: Pull complete  Digest: sha256:3debe666e4b65c116e2814ae070b54079654ca561745491d51138230ca21c673 Status: Downloaded newer image for rizo928/mywebsql-flex:latest docker.io/rizo928/mywebsql-flex:latest   

四、部署MyWebSQL工具

1.编辑docker-compose.yaml

[root@node mywebsql]# cat docker-compose.yaml  version: '3.0' services:   db:     image: mariadb:10.5     container_name: mywebsql-db     restart: always     environment:       - MYSQL_ROOT_PASSWORD=mindoc       - MYSQL_DATABASE=mindoc       - MYSQL_USER=mindoc       - MYSQL_PASSWORD=mindoc     volumes:       - /data/mindoc/db:/var/lib/mysql  # Requested, specifies the path to MySQL data persistent store.     networks:       - mywebsql     ports:       - 3422:3306   webmysql:     image: rizo928/mywebsql-flex      container_name: mywebsql     restart: always     volumes:       - /data/mywebsql/config:/config     ports:       - 9088:80     depends_on:       - db     networks:       - mywebsql  networks:   mywebsql:  

2.创建MyWebSQL容器

[root@node mywebsql]# docker-compose up -d Creating network "mywebsql_mywebsql" with the default driver Creating mywebsql-db ... done Creating mywebsql    ... done 

3.查看MyWebSQL容器状态

[root@node mywebsql]# docker ps CONTAINER ID   IMAGE                          COMMAND                  CREATED             STATUS             PORTS                                                  NAMES 0fb0ebac00d6   mysql:5.7                      "docker-entrypoint.s…"   About an hour ago   Up About an hour   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp   some-mysql 3fa0565b18d8   rizo928/mywebsql-flex          "/sbin/my_init"          2 hours ago         Up 37 minutes      0.0.0.0:9088->80/tcp, :::9088->80/tcp                  mywebsql 3f49db3d5264   mariadb:10.5                   "docker-entrypoint.s…"   2 hours ago         Up 2 hours         0.0.0.0:3422->3306/tcp, :::3422->3306/tcp              mywebsql-db 

4.查看MyWebSQL日志

[root@node mywebsql]# docker logs mywebsql Starting pre-service scritps in /etc/my_init.*** Running: /etc/my_init.d/startup.sh mywebsql installed... config directory exists /config is Empty starting rc.local scritps *** Running: /etc/rc.local Booting runit daemon... Process runsvdir running with PID 222 Begin shutting down runit services... Starting pre-service scritps in /etc/my_init.*** Running: /etc/my_init.d/startup.sh mywebsql installed... config directory exists we are already configured *** Running: /etc/rc.local starting rc.local scritps Booting runit daemon... Process runsvdir running with PID 236 Begin shutting down runit services... Starting pre-service scritps in /etc/my_init.*** Running: /etc/my_init.d/startup.sh mywebsql installed... config directory exists we are already configured *** Running: /etc/rc.local starting rc.local scritps Booting runit daemon... Process runsvdir running with PID 236 httpd (pid 245) already running Begin shutting down runit services... Starting pre-service scritps in /etc/my_init.*** Running: /etc/my_init.d/startup.sh mywebsql installed... config directory exists we are already configured *** Running: /etc/rc.local starting rc.local scritps Booting runit daemon... Process runsvdir running with PID 236 Begin shutting down runit services... Starting pre-service scritps in /etc/my_init.*** Running: /etc/my_init.d/startup.sh mywebsql installed... config directory exists we are already configured *** Running: /etc/rc.local starting rc.local scritps Booting runit daemon... Process runsvdir running with PID 236 httpd (pid 245) already running  

五、进入MyWebSQL的web登录页

国产数据库实战之Docker部署MyWebSQL数据库管理工具

六、检查TiDB集群状态

1.检查TiDB各组件容器状态

[root@server ~]# docker ps -a CONTAINER ID   IMAGE                                                                 COMMAND                  CREATED      STATUS          PORTS                                                                                                                                  NAMES e3a109b3ac77   pingcap/tispark:v2.1.1                                                "/opt/spark/sbin/sta…"   3 days ago   Up 4 minutes    0.0.0.0:38081->38081/tcp, :::38081->38081/tcp                                                                                          tidb-docker-compose-master_tispark-slave0_1 750f938b9669   pingcap/tispark:v2.1.1                                                "/opt/spark/sbin/sta…"   3 days ago   Up 4 minutes    0.0.0.0:7077->7077/tcp, :::7077->7077/tcp, 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp                                                   tidb-docker-compose-master_tispark-master_1 7fd728cc1019   pingcap/tidb:latest                                                   "/tidb-server --stor…"   3 days ago   Up 7 seconds    0.0.0.0:4000->4000/tcp, :::4000->4000/tcp, 0.0.0.0:10080->10080/tcp, :::10080->10080/tcp                                               tidb-docker-compose-master_tidb_1 0e18dbcd2efe   pingcap/tikv:latest                                                   "/tikv-server --addr…"   3 days ago   Up 20 seconds   20160/tcp                                                                                                                              tidb-docker-compose-master_tikv0_1 3789709f53b1   pingcap/tikv:latest                                                   "/tikv-server --addr…"   3 days ago   Up 4 minutes    20160/tcp                                                                                                                              tidb-docker-compose-master_tikv2_1 304c90121b1c   pingcap/tikv:latest                                                   "/tikv-server --addr…"   3 days ago   Up 4 minutes    20160/tcp                                                                                                                              tidb-docker-compose-master_tikv1_1 d3f461f3e313   pingcap/pd:latest                                                     "/pd-server --name=p…"   3 days ago   Up 19 seconds   2380/tcp, 0.0.0.0:49154->2379/tcp, :::49154->2379/tcp                                                                                  tidb-docker-compose-master_pd1_1 6b2a18f4b823   prom/pushgateway:v0.3.1                                               "/bin/pushgateway --…"   3 days ago   Up 19 seconds   9091/tcp                                                                                                                               tidb-docker-compose-master_pushgateway_1 51deb002f753   grafana/grafana:6.0.1                                                 "/run.sh"                3 days ago   Up 18 seconds   0.0.0.0:3000->3000/tcp, :::3000->3000/tcp                                                                                              tidb-docker-compose-master_grafana_1 82b528f74a0c   pingcap/pd:latest                                                     "/pd-server --name=p…"   3 days ago   Up 4 minutes    2380/tcp, 0.0.0.0:49153->2379/tcp, :::49153->2379/tcp                                                                                  tidb-docker-compose-master_pd2_1 0939bfabe52b   prom/prometheus:v2.2.1                                                "/bin/prometheus --l…"   3 days ago   Up 17 seconds   0.0.0.0:9090->9090/tcp, :::9090->9090/tcp                                                                                              tidb-docker-compose-master_prometheus_1 b2d645e3b30a   pingcap/tidb-vision:latest                                            "/bin/sh -c 'sed -i …"   3 days ago   Up 4 minutes    80/tcp, 443/tcp, 2015/tcp, 0.0.0.0:8010->8010/tcp, :::8010->8010/tcp                                                                   tidb-docker-compose-master_tidb-vision_1 c3cb9f6acc84   pingcap/pd:latest                                                     "/pd-server --name=p…"   3 days ago   Up 14 seconds   2380/tcp, 0.0.0.0:49155->2379/tcp, :::49155->2379/tcp                                                                                  tidb-docker-compose-master_pd0_1  

2.本地访问TiDB集群

[root@server ~]#  mysql -h 127.0.0.1 -P 4000 -u root Welcome to the MariaDB monitor.  Commands end with ; or g. Your MySQL connection id is 5 Server version: 5.7.25-TiDB-v5.0.1 TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible  Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.  Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.  MySQL [(none)]> show databases; +--------------------+ | Database           | +--------------------+ | INFORMATION_SCHEMA | | METRICS_SCHEMA     | | PERFORMANCE_SCHEMA | | ittest             | | mysql              | | test               | +--------------------+ 6 rows in set (0.01 sec)  

七、配置MyWebSQL的特定数据库实例

1.编辑server.php

新增以下模块

                'TiDB-remote'          => array(                                              'host'     => '192.168.3.240:4000',                                              'driver'   => 'mysql5'                                          )  

2.查看server.php

[root@node config]# cat servers.php  <?php /**  * This file is a part of MyWebSQL package  * defining more that one server here will give user the option to select a server at login time  * Notes:  *   Server list is used only when authentication type is LOGIN  *  * @file:      config/servers.php  * @author     Samnan ur Rehman  * @copyright  (c) 2008-2014 Samnan ur Rehman  * @web        http://mywebsql.net  * @license    http://mywebsql.net/license  */   // add or remove list of servers below   // please make sure you have the proper extensions enabled in your php config  // to successfully connect to servers other than MySQL   // valid drivers types are:  // mysql4, mysql5, mysqli, sqlite, sqlite3, pgsql   // for sqlite driver:  //   'host' should be the folder name where sqlite databases are saved,  //   'user' and 'password' options should be set for additional security   // if true, a free form server name will be allowed to be entered instead of selecting  // existing one from the list  $ALLOW_CUSTOM_SERVERS = TRUE;   // if the above is true, only the following server types will be allowed  // sqlite is not recommended here, in order to avoid possible file system attacks  $ALLOW_CUSTOM_SERVER_TYPES = "mysql,pgsql";   $SERVER_LIST = array(   'Localhost MySQL'           => array(                                'host'     => 'localhost',                                'driver'   => extension_loaded('mysqli') ? 'mysqli' : 'mysql5'                            ), #                'remote  MySQL'             => array(^M #                                             'host'     => '192.168.3.152:3776',^M #                                             'driver'   => extension_loaded('mysqli') ? 'mysqli' : 'mysql5'^M #                                         ),^M    'SQLite Databases'          => array(                                'host'     => 'c:/sqlitedb/',                                'driver'   => 'sqlite3',                                'user'     => 'root',    // set this yourself                                'password' => 'sqlite'  // set this yourself                            ),    'Localhost PostgreSQL'     => array(                                'host'     => 'localhost',                                'driver'   => 'pgsql'                            ),                  'TiDB-remote'          => array(                                'host'     => '192.168.3.240:4000',                                'driver'   => 'mysql5'                            )     /*'MySQL Proxy Server'  => array(                                'host'     => 'localhost:4040',                                'driver'   => 'mysql5'                            ),   'MySQL 4'             => array(                                'host'     => 'localhost',                                'driver'   => 'mysql4'                            ),   */  ); ?>   

3.重启MyWebSQL容器

[root@node config]# docker restart mywebsql mywebsql  

八、MyWebSQL工具连接TiDB数据库

1.进入MyWebSQL的登录页

国产数据库实战之Docker部署MyWebSQL数据库管理工具

2.连接TiDB数据库

国产数据库实战之Docker部署MyWebSQL数据库管理工具

3.查看TiDB的用户

国产数据库实战之Docker部署MyWebSQL数据库管理工具

4.查看数据表

国产数据库实战之Docker部署MyWebSQL数据库管理工具


原文始发于微信公众号(运维江湖客):国产数据库实战之Docker部署MyWebSQL数据库管理工具

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/196284.html

(0)
小半的头像小半

相关推荐

发表回复

登录后才能评论
极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!