SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111)

I recently acquired a running PIWIK system however I had to recover just about everything. I have since given myself root access to both my VM and Mysql server. However when I update the config.ini file with the new Database connection info it doesn’t seem to take. I continually get

SQLSTATE[HY000] [2003] Can’t connect to MySQL server on ‘127.0.0.1’ (111)

when attempting to login. I can access the database just fine with my new root password but I can’t seem to give that data to the piwik config files to it can use it.

I updated the config.ini to and am now kind of at a loss on what I need to do to get piwik to use this new configuration data. IF it matters the previous config was using a salt under General.

[database]
host = 127.0.0.1
username = root
password = xxxxxxxx
dbname = piwik
tables_prefix = piwik_

Thanks in advanced

Unfortunately I do not have a solution, but I do have the same problem.

Did you have any luck getting around it? Restarting MySQL is not working as well as it used to!

Thanks.

PU

Make sure the “config” directory in your Piwik install directory has full 777 permissions.

If you delete (or rename) file “config/config.ini.php” and then launch Piwik, you should get to the Installation wizard so you can enter the database connection paramaters and continue from there. Piwik should also discover that the database tables already exist and use them.

When Piwik is working again, you can reset the “config” directory and its contents to read-only.

I tried both ways: use config.init.php file and rename the config.ini.php to something else and went through the installtion page. I still get the same error.
I got this error: 500
GET request to piwik.php failed. Try whitelisting this URL from HTTP Authentication and disable mod_security (you may have to ask your webhost). For more information about the error, check your web server error log file.
After making this change, restart your web server.

so I added.htaccess file under /piwik folder and include it in the Apache server config file. The error is still there. Then I ignore it and move to the next page, then I got this error:
Error in Piwik: Cannot connect to the database: SQLSTATE[HY000] [2003] Can't connect to MySQL server…
I restarted mysqld . the error is still there. I am able to connect to mysql database from the server.

please advise,

The only thing I can suggest is that the permissions on your Piwik installation are wrong.

My server will only work if the entire installation has the permissions set to 755, except for the /tmp and /config directories and their contents, which need 777. After the Piwik configuration is complete, the /config directory and its contents should be set to 755.

You should also make sure that the memory limit for PHP scripts, as defined in the php.ini configuration file is at least 128 Mb. You may need to ask your server support to adjust this memory limit for you.

If you still get that 500 server error, you need get your server support involved. They should be able to tell you the cause of that error after they check the server’s log files.