如何从 mariadb 中的 SHOW MASTER STATUS 检索 'Position' 的值

how to retrieve value of 'Position' from SHOW MASTER STATUS in mariadb

如何从 docker 外部的 MariaDB(运行 in docker 容器)中的 'SHOW MASTER STATUS' 查询表达式中仅检索 'position' 值容器 ?

类似的东西,我有以下内容:-

+-------------------+----------+--------------+------------------+
| File              | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------+----------+--------------+------------------+
| master-bin.000003 |      375 |              |                  |
+-------------------+----------+--------------+------------------+

并且只需要使用 bash 脚本获取位置值?

请尽快帮忙

当 MariaDB 运行 在 docker 容器内并且想要从 docker 容器外的 MariaDB/MySQL 中的“SHOW MASTER STATUS”中检索文件和位置值时,使用bash 中的以下命令:-

文件

docker exec -it <mariadb_container_name> bash -c "mysql -u<username> -p<password> -Ne 'show master status' | awk '{print }' | cut -f1"

位置

docker exec -it <mariadb_container_name> bash -c "mysql -u<username> -p<password> -Ne 'show master status' | awk '{print }' | cut -f2"