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

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用系列 2核4GB
简介: 【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.查看数据表

在这里插入图片描述

相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
23天前
|
存储 缓存 数据库
数据库数据删除策略:硬删除vs软删除的最佳实践指南
在项目开发中,“删除”操作常见但方式多样,主要分为硬删除与软删除。硬删除直接从数据库移除数据,操作简单、高效,但不可恢复;适用于临时或敏感数据。软删除通过标记字段保留数据,支持恢复和审计,但增加查询复杂度与数据量;适合需追踪历史或可恢复的场景。两者各有优劣,实际开发中常结合使用以满足不同需求。
77 4
|
2月前
|
SQL 关系型数据库 数据库
【YashanDB知识库】OM仲裁节点故障后手工切换方案和yasom仲裁重新部署后重新纳管数据库集群方案
本文介绍了主备数据库集群的部署、OM仲裁故障切换及重新纳管的全过程。首先通过解压软件包并调整安装参数完成数据库集群部署,接着说明了在OM仲裁故障时的手动切换方案,包括关闭自动切换开关、登录备节点执行切换命令。最后详细描述了搭建新的yasom仲裁节点以重新纳管数据库集群的步骤,如生成配置文件、初始化进程、执行托管命令等,确保新旧系统无缝衔接,保障数据服务稳定性。
|
2月前
|
数据库
【YashanDB知识库】数据库一主一备部署及一主两备部署时,主备手动切换方法及自动切换配置
【YashanDB知识库】数据库一主一备部署及一主两备部署时,主备手动切换方法及自动切换配置
【YashanDB知识库】数据库一主一备部署及一主两备部署时,主备手动切换方法及自动切换配置
|
2天前
|
负载均衡 算法 关系型数据库
大数据大厂之MySQL数据库课程设计:揭秘MySQL集群架构负载均衡核心算法:从理论到Java代码实战,让你的数据库性能飙升!
本文聚焦 MySQL 集群架构中的负载均衡算法,阐述其重要性。详细介绍轮询、加权轮询、最少连接、加权最少连接、随机、源地址哈希等常用算法,分析各自优缺点及适用场景。并提供 Java 语言代码实现示例,助力直观理解。文章结构清晰,语言通俗易懂,对理解和应用负载均衡算法具有实用价值和参考价值。
大数据大厂之MySQL数据库课程设计:揭秘MySQL集群架构负载均衡核心算法:从理论到Java代码实战,让你的数据库性能飙升!
|
2月前
|
关系型数据库 MySQL 数据库连接
docker拉取MySQL后数据库连接失败解决方案
通过以上方法,可以解决Docker中拉取MySQL镜像后数据库连接失败的常见问题。关键步骤包括确保容器正确启动、配置正确的环境变量、合理设置网络和权限,以及检查主机防火墙设置等。通过逐步排查,可以快速定位并解决连接问题,确保MySQL服务的正常使用。
372 82
|
11天前
|
Ubuntu Linux Docker
Docker容器的实战讲解
这只是Docker的冰山一角,但是我希望这个简单的例子能帮助你理解Docker的基本概念和使用方法。Docker是一个强大的工具,它可以帮助你更有效地开发、部署和运行应用。
70 27
|
23天前
|
SQL 运维 监控
数据库国产化选型?YashanDB 给中大型企业的五个答案
近两年,“国产数据库”成为企业数字化升级的重要议题。YashanDB作为新一代国产关系型数据库,以完整产品矩阵解决企业核心关切:通过图形化工具提升开发效率;提供自动化迁移平台简化数据库切换;云管理工具减轻运维负担;支持复杂业务场景;拥有成熟团队保障企业级服务。YashanDB不仅是“可替代”,更是“更可靠”的选择,助力企业实现高效、可控的数据库升级。
|
2月前
|
SQL 数据库 Docker
【赵渝强老师】在Docker中运行达梦数据库
本文介绍了在Docker容器中部署达梦数据库(DM 8)的具体步骤,包括创建文件夹、下载安装包、导入镜像、启动容器、登录数据库及查看状态等操作。同时,通过视频讲解辅助理解。文中还分析了将数据库服务容器化的潜在问题,如数据安全性、硬件资源争用、网络带宽占用和额外隔离带来的挑战,指出数据库服务在生产环境中可能不适合容器化的原因。
【赵渝强老师】在Docker中运行达梦数据库
|
2月前
|
存储 开发工具 开发者
揭秘 Microsoft.Docker.SDK:让容器开发更轻松的强大工具揭秘
随着云计算和容器技术的快速发展,`Docker` 已经成为容器化技术的事实标准。`Microsoft` 作为 `Docker` 的主要支持者和参与者,推出了 `Microsoft.Docker.SDK`,旨在帮助开发者更轻松地进行容器开发。本文将深入揭秘 Microsoft.Docker.SDK 的功能、使用方法以及它在容器开发中的应用。
83 12

热门文章

最新文章

AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等