我可以从命令行输出文本文件中的SHOW ENGINE INNODB STATUS\G;
。还有使用mysqli_fetch_array()或mysqli_fetch_assoc()
以下也是可能的,因为我们有列名(类型,名称,状态)
mysql> SHOW ENGINE PERFORMANCE_SCHEMA STATUS;
+--------------------+-------------------------------------------------------------+----------+
| Type | Name | Status |
+--------------------+-------------------------------------------------------------+----------+
| performance_schema | events_waits_current.size | 186 |
现在,我想通过php在Web浏览器中打印SHOW ENGINE INNODB STATUS\G;
的完整输出。
我已经通过了var_dump()和serialize(),但却无法真正开始工作。请帮忙
网络浏览器中的预期输出
------------
TRANSACTIONS
------------
Trx id counter 11271
Purge done for trx's n:o < 11271 undo n:o < 0 state: running but idle
History list length 36
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 421919568688976, not started
0 lock struct(s), heap size 1136, 0 row lock(s)
--------
FILE I/O
--------
I/O thread 0 state: waiting for completed aio requests (insert buffer thread)
I/O thread 1 state: waiting for completed aio requests (log thread)
I/O thread 2 state: waiting for completed aio requests (read thread)
另外,我不想创建一个文件并从php
中读取它echo file_get_contents( "innodb_status.php" );
答案 0 :(得分:1)
使用var_export工作但它包含数组键。
echo "<pre>";
var_export(array_values($innodb_row));
echo "</pre>";
以下工作完美且给出了所需的输出
$remoteconnect = mysqli_connect("host","user","pass","","port","");
if (!$remoteconnect)
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else {
$innodb = "show engine innodb status" ;
$innodb_result = mysqli_query($remoteconnect,$innodb);
if (!$innodb_result) {
printf("Error: %s\n", mysqli_error($remoteconnect));
exit(); }
while($innodb_row = mysqli_fetch_array($innodb_result)) {
echo "<pre>".$innodb_row[0].$innodb_row[1].$innodb_row[2]."</pre>";
}
}
mysqli_close($remoteconnect);