Giter VIP home page Giter VIP logo

Comments (8)

hcymysql avatar hcymysql commented on July 18, 2024
    $get_db_ip="select ip,dbname,user,pwd,port from dbinfo where dbname='${db_max_name}'";
$result2 = mysqli_query($con,$get_db_ip);      
list($ip,$dbname,$user,$pwd,$port) = mysqli_fetch_array($result2);
$con_explain = mysqli_connect("$ip","$user","$pwd","$dbname","$port") or die("数据库链接错误".mysql_error());
mysqli_query($con_explain,"set names utf8");
    $get_sql_explain = "EXPLAIN $sample_sql";
$result3 = mysqli_query($con_explain,$get_sql_explain);
while($row = mysqli_fetch_array($result3)){

以上的代码意思是:从dbinfo表里获取被监控主机MySQL的IP相关信息,然后与其建立会话连接。将查询的结果用函数mysqli_fetch_array取出来,存放入数组$row里,并循环打印出来。
估计是你的账号权限,不能远程访问吧?你创建一个'admin'@'%'远程账号试试?

from slowquery.

hcymysql avatar hcymysql commented on July 18, 2024

您好,大佬explain过程中出现一下问题,麻烦帮指导下,谢谢

image
通过慢查询explain过程中出现调用dbinfo数据链接报错。
尝试手动把$con_explain = mysqli_connect(修改成数据库连接信息,不在报数据库链接失败)
但是,explain没有任何显示
image

$get_sql = "select sample,db_max from mysql_slow_query_review_history where checksum=${checksum} limit 1";

你看下 mysql_slow_query_review_history这个表里有数据吗?

from slowquery.

kells-h avatar kells-h commented on July 18, 2024
    $get_db_ip="select ip,dbname,user,pwd,port from dbinfo where dbname='${db_max_name}'";
$result2 = mysqli_query($con,$get_db_ip);      
list($ip,$dbname,$user,$pwd,$port) = mysqli_fetch_array($result2);
$con_explain = mysqli_connect("$ip","$user","$pwd","$dbname","$port") or die("数据库链接错误".mysql_error());
mysqli_query($con_explain,"set names utf8");
    $get_sql_explain = "EXPLAIN $sample_sql";
$result3 = mysqli_query($con_explain,$get_sql_explain);
while($row = mysqli_fetch_array($result3)){

上面的代码的意思是:从dbinfo表里获取被监视主机MySQL的IP相关信息,然后建立会话连接。将查询的结果用函数mysqli_fetch_array取来,放入入$$ row里,并循环打印出来。
估计是你的账号权限,不能远程访问吧?你创建一个'admin'@'%'远程账号试试?
权限都是管理员账户。测试可以访问的
image
我使用的apache2.4.6 php5.4 mysql5.7

from slowquery.

kells-h avatar kells-h commented on July 18, 2024

您好,表中有慢sql数据的

image

from slowquery.

hcymysql avatar hcymysql commented on July 18, 2024

您好,表中有慢sql数据的

image

select sample,db_max from mysql_slow_query_review_history where checksum=${checksum} limit 1
手工查询下,可以查出来吗?

from slowquery.

kells-h avatar kells-h commented on July 18, 2024

感谢答复。
问题已经找到,pt分析mysql5.7生成checksum包含数字和字母。故脚本写入到sql_db的时候无法写入。通过修改字段为varchar类型。数据写入正常。
然而也需要修改slowquery_explain.php中的'${checksum}' 加上引号

from slowquery.

kells-h avatar kells-h commented on July 18, 2024

from slowquery.

hcymysql avatar hcymysql commented on July 18, 2024

checksum修改成了varchar类型,需要把脚本修改一下,问题解决掉了。 select sample,db_max from mysql_slow_query_review_history where checksum='${checksum}' limit 1 非常感谢大佬   Kells-Huang  

------------------ 原始邮件 ------------------ 发件人: "hcymysql"<[email protected]>; 发送时间: 2019年11月21日(星期四) 晚上6:21 收件人: "hcymysql/slowquery"<[email protected]>; 抄送: "忘却折@脊"<[email protected]>; "Author"<[email protected]>; 主题: Re: [hcymysql/slowquery] explain数据不展示 (#4) 您好,表中有慢sql数据的 select sample,db_max from mysql_slow_query_review_history where checksum=${checksum} limit 1 手工查询下,可以查出来吗? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

感谢分享。我修改下代码。

from slowquery.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.