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

本文涉及的产品
RDS MySQL DuckDB 分析主实例,基础系列 4核8GB
RDSClaw,2核4GB
RDS DuckDB + QuickBI 企业套餐,8核32GB + QuickBI 专业版
简介: 【10月更文挑战第23天】国产数据实战之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; 5h 7min 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.d
*** 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.d
*** 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.d
*** 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.d
*** 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.d
*** 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登录页

在这里插入图片描述

六、检查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

新增以下模块
```cpp

           'TiDB-remote'          => array(
                                         'host'     => '192.168.3.240:4000',
                                         'driver'   => 'mysql5'
                                     )
## 2.查看server.php

```cpp
[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的登录页

在这里插入图片描述

2.连接TiDB数据库

在这里插入图片描述

3.查看TiDB的用户

在这里插入图片描述

4.查看数据表

在这里插入图片描述

相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
相关文章
|
6月前
|
SQL 关系型数据库 数据库
Python SQLAlchemy模块:从入门到实战的数据库操作指南
免费提供Python+PyCharm编程环境,结合SQLAlchemy ORM框架详解数据库开发。涵盖连接配置、模型定义、CRUD操作、事务控制及Alembic迁移工具,以电商订单系统为例,深入讲解高并发场景下的性能优化与最佳实践,助你高效构建数据驱动应用。
781 7
|
人工智能 关系型数据库 OLAP
聚光灯已就位!阿里云瑶池数据库邀你征战Cursor首届实战征文大赛
阿里云AnalyticDB携手Cursor中文社区,正式发起首届实战征文大赛!我们诚邀开发者融合Cursor的智能编程能力与AnalyticDB PostgreSQL提供的Supabase服务进行项目开发,让优秀项目被专家看见、被机遇拥抱!
|
6月前
|
监控 Kubernetes 安全
还没搞懂Docker? Docker容器技术实战指南 ! 从入门到企业级应用 !
蒋星熠Jaxonic,技术探索者,以代码为笔,在二进制星河中书写极客诗篇。专注Docker与容器化实践,分享从入门到企业级应用的深度经验,助力开发者乘风破浪,驶向云原生新世界。
725 51
还没搞懂Docker? Docker容器技术实战指南 ! 从入门到企业级应用 !
|
7月前
|
数据采集 关系型数据库 MySQL
python爬取数据存入数据库
Python爬虫结合Scrapy与SQLAlchemy,实现高效数据采集并存入MySQL/PostgreSQL/SQLite。通过ORM映射、连接池优化与批量提交,支持百万级数据高速写入,具备良好的可扩展性与稳定性。
|
7月前
|
关系型数据库 MySQL Linux
事项驱动的项目管理工具Dectask的Docker安装教程
Dectask是智能驱动的新一代项目协作工具,本人介绍其Docker安装教程。
204 2
|
8月前
|
存储 数据管理 数据库
数据字典是什么?和数据库、数据仓库有什么关系?
在数据处理中,你是否常困惑于字段含义、指标计算或数据来源?数据字典正是解答这些问题的关键工具,它清晰定义数据的名称、类型、来源、计算方式等,服务于开发者、分析师和数据管理者。本文详解数据字典的定义、组成及其与数据库、数据仓库的关系,助你夯实数据基础。
数据字典是什么?和数据库、数据仓库有什么关系?
|
7月前
|
人工智能 Java 关系型数据库
使用数据连接池进行数据库操作
使用数据连接池进行数据库操作
203 11
|
7月前
|
存储 数据库 开发者
Python SQLite模块:轻量级数据库的实战指南
本文深入讲解Python内置sqlite3模块的实战应用,涵盖数据库连接、CRUD操作、事务管理、性能优化及高级特性,结合完整案例,助你快速掌握SQLite在小型项目中的高效使用,是Python开发者必备的轻量级数据库指南。
628 0
|
7月前
|
人工智能 数据库 iOS开发
DBeaver Ultimate Edtion 25.2 发布 - 通用数据库工具
DBeaver Ultimate Edtion 25.2 Multilingual (macOS, Linux, Windows) - 通用数据库工具
723 0
下一篇
开通oss服务