Question:
Hello I have vps on debian. There was a need to find out through php status mysql. Accordingly, I run:
echo exec('/usr/sbin/service mysql status');
Issues
MySQL is stopped..
Moreover, if the same code
/usr/sbin/service mysql status
run from console, gives normal statistics (while I work, mysql is on).
How is this possible? Why doesn't he swear in any way, but gives incorrect data? And, actually, what to do, how to fix it?
Help, please, I really need it.
UPD. I need to run SH and not anything else
The question is closed, I bypassed it from the other side. As the saying goes – until you ask someone, you won't understand how to fix it. The fact that the answers did not come to the cashier at all does not matter here.
Answer:
I wonder what he writes about stopped … Most likely there are not enough rights.
$ /usr/sbin/service mysql status [info] MySQL (Percona Server) is stopped..
$ sudo /usr/sbin/service mysql status [info] /usr/bin/mysqladmin Ver 8.42 Distrib 5.6.15, for Linux on x86_64 Copyright (c) 2009-2013 Percona LLC and/or its affiliates Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Server version 5.6.15-63.0 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/run/mysqld/mysqld.sock Uptime: 3 days 1 hour 45 min 34 sec Threads: 1 Questions: 133835 Slow queries: 0 Opens: 12287 Flush tables: 1 Open tables: 252 Queries per second avg: 0.504.
If so?
exec('sudo /usr/sbin/service mysql status', $result); var_dump($result);
There is also a mysql-stat function. Maybe it will suit you.
How did you get around? Interestingly)