1

I just restarted the MySQL service.

I know how to get the current Uptime, but by any chance is there a way to get the uptime before last restart ?

Thanks

3
  • I don't think so...
    – alexus
    Apr 4, 2016 at 15:46
  • 1
    You might be able to reconstruct this from log file entries regarding MySQL starts and stops ...
    – Sven
    Apr 4, 2016 at 15:52
  • Good idea Sven, log was disabled but I can see it in syslog. Now I just have to crawl 30+ logs files.gz... Thanks :)
    – FLX
    Apr 4, 2016 at 16:00

1 Answer 1

1

I had almost the same problem. I solved it this way:

1) Insert into my.cnf this line:

init_file = /some-path/startup.sql

2) In the file startup.sql you have these MySQL commands:

CREATE TABLE IF NOT EXISTS MySqlServerLog ( MySqlServerStarted DATETIME );
INSERT INTO MySqlServerLog SET MySqlServerStarted = NOW();

Each time you start/restart the MySQL server this script is executed and it logs very simple the exact start time.

The uptime can be then very easy calculated for each start/restart.

1
  • Good tip, will be useful for other things too ! I'm still a bit disappointed that they have no buitin stats or something
    – FLX
    Apr 5, 2016 at 10:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .