0

After reading multiple questions of users with problems like:

  • forgot password
  • installed multiple instances of MySQL
  • forgot to start MySQL
  • etc. etc

I started to consider if it is actually possible to conclude from the error page if MySQL is running at all?

enter image description here

Questions with the same type of answers:

But does the error page actually say this is a mysql server response or it couldn't connect (server isn't running for instance)

Take the following code:

<?php
//Step1
 $db = mysqli_connect('localhost','username','password','database_name')
 or die('Error connecting to MySQL server.');
?>

If one of the inputs is incorrect you will get the error:

Error connecting to MySQL server.

This could be modified into a nice looking error message (as the image above).

So does the error actually prove that MySQL is running or not?

Community
  • 1
  • 1
davejal
  • 6,009
  • 10
  • 39
  • 82

2 Answers2

1

I found a video of a walkthrough on how to fix this error. In the video you can see the servers are running. I was pretty curious about this whole issue.

Link to Youtube: https://www.youtube.com/watch?v=8fK_DYvosA8

I'm assuming if that's how it worked for the video, that's how it works in general. I'm working off the idea that something can't give you an error message unless it's running.

Jenny Holder
  • 63
  • 1
  • 11
0

Sort of. phpMyAdmin generally returns the error message that it gets from MySQL, so for instance if the isn't a MySQL daemon listening on on the TCP/IP protocol, phpMyAdmin shows:

#2003 - Can't connect to MySQL server on '127.0.0.1' (111) — The server is not responding.

For an incorrect username or password, the error message is:

#1045 - Access denied for user 'root'@'localhost' (using password: YES)

"Invalid settings" usually means you have conflicting directives or incorrect information in one of your configuration statements. Without seeing your config.inc.php it's difficult to guess what's wrong here, but this also can mean something went wrong between the PHP library itself and MySQL.

The rejected connection message you posted can also have several causes.

Basically, to directly answer your question, you often can tell based on the error message returned by MySQL or the PHP library (which is the message phpMyAdmin shows). "Can't connect" means phpMyAdmin couldn't get any response from the MySQL daemon, which could have several causes but most often means MySQL isn't running. Most of the other error messages mean it's running but there was a problem connecting. Generally the error message contains some information about why.

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43