NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.
Forum Discussion
egeek
Oct 17, 2011Aspirant
Wordpress - Error establishing a database connection
Hi guys,
I have been trying to get wordpress up and running for about a day.
I followed the wordpress guide exactly, then found i needed to provide an updated PHP, which i obtained from ReadyNasExtras website.
Everything seems to be in order, but the install.php page keeps telling me it cant connect. I'm certain i have the sql credentials all correct.
I have installed other addons as well. MyPHPAdmin and MySQLON. I cant log into the myphpadmin because it says it wont allow login without passwords (even though i cofigured it to allow it to do so), but that's a side issue to the WordPress issue i have.
The MySQL service appears to be running, and i can log into the MySQL prompt ok. I have looked at may guides on the net. Most don't seem to address my issue, some discuss directory and file permissions, but so far i was unwilling to go and play around with them until i sought advice here.
Any more idea's, places to check, things i may have missed?
I have been trying to get wordpress up and running for about a day.
I followed the wordpress guide exactly, then found i needed to provide an updated PHP, which i obtained from ReadyNasExtras website.
Everything seems to be in order, but the install.php page keeps telling me it cant connect. I'm certain i have the sql credentials all correct.
I have installed other addons as well. MyPHPAdmin and MySQLON. I cant log into the myphpadmin because it says it wont allow login without passwords (even though i cofigured it to allow it to do so), but that's a side issue to the WordPress issue i have.
The MySQL service appears to be running, and i can log into the MySQL prompt ok. I have looked at may guides on the net. Most don't seem to address my issue, some discuss directory and file permissions, but so far i was unwilling to go and play around with them until i sought advice here.
Any more idea's, places to check, things i may have missed?
9 Replies
Replies have been turned off for this discussion
- michelefacciniAspirantLook at this post http://www.readynas.com/forum/viewtopic.php?f=7&t=57504...I replace localhost with % (which means any host) and got it to work....
- egeekAspirantThanks michelefaccini,
I can't log into PHPmyAdmin though, so which 'localhost' entry in which file to i edit? - egeekAspirantI'm not sure if this is related but i also have to reboot the NAS to get mySQL up and running if i shut it down on the cli. If i try to
mysqladmin shutdown
mysql &
I getmysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
I've seen this error reported online a lot too....... - michelefacciniAspirantDid you have access to phpMyadmin and to mysql (through the putty shell) before installing Wordpress or you installed everything together ( I mean php + Wordpress) ?
- sphardy1Apprentice
egeek wrote: I'm not sure if this is related but i also have to reboot the NAS to get mySQL up and running if i shut it down on the cli.
Use MySQLON to start & stop mysql - there are specific command line options needed to start mysql on ReadyNAS
Either enable & disable via the GUI in Frontview, or from SSH you can use:
/etc/frontview/addons/bin/MYSQLON/start.sh
/etc/frontview/addons/bin/MYSQLON/stop.sh - egeekAspirant@michelefaccini: I initially just followed the ReadyNas instructions at http://www.readynas.com/?p=213. The first error i got was WP telling me I needed a newer version of PHP (for SPARC) which i got from readynasextras. The PHP update went flawlessly (as far as i could tell) and then wordpress rendered it's first page for me, which was the Error connecting to Database page. I then started getting the "error: 'Can't connect to local MySQL server through socket......" error which i resolved with a system restart, and now, thanks to Sphardy's advice, i can stop and start MySQL without the restart.
PHPMyAdmin I installed last in an attempt to resolve the database connection error. But to this point i have not been able to log into it because it wont allow Login without Password ("Login without a password is forbidden by configuration (see AllowNoPassword)") despite following the instructions here http://readynasxtras.com/content/after- ... server-why
I think what i will try is removing the database i created initially and creating a new one, and see if that works.
Thanks so far for your help. - egeekAspirantNew database, still no joy.
Here are some links to my.cnf (mysql config file) and wp-config.php (sanitised) and my php.ini file from the /etc/php5/apache2 folder.
http://dl.dropbox.com/u/13903506/etc-mysql-my.cnf.txt
http://dl.dropbox.com/u/13903506/wp-config.php
http://dl.dropbox.com/u/13903506/php.ini
EDIT:
http://dl.dropbox.com/u/13903506/config ... p.dpkg-new
^^the PHPmyadmin config file
If there is something in there i am missing I can't see it. - egeekAspirantI found a little PHP test code to test PHP's connection to MySQL.
<?php
$db = @mysql_connect('localhost', 'geekmason', 'XXXXXXX');
if (!$db) echo "connection failed";
else echo "connection succeeded";
?>
It output "connection failed" in the browser window
EDIT: I changed 'localhost' to 127.0.0.1 and to the IP address of the NAS. Still did not work. I assume doing this in the test file reproduces the same conditions the wp-config.php and the results seem to be the same.
EDIT2: I tried a new test code from php.net<?php
$link = mysql_connect('localhost', 'geekmason', 'XXXXXXXX');
if (!$link) {
die('Could not fracking connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
This out outputted (via mysql_error() i assume) an interesting bit of dialogue
"Could not fracking connect: No such file or directory" (ignore my insertion of "fracking", i was just doing this to delineate from the other test file ;))
EDIT3:
Tried this, also from php.net<?php
// we connect to localhost and socket e.g. /tmp/mysql.sock
// variant 1: omit localhost
$link = mysql_connect('localhost:/var/run/mysqld/mysqld.sock', 'geekmason', 'XXXXXXXX');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
Interestingly, this one connects. It initially refused because i had changed the MySQL password to OLD_PASSWORD type during troubleshooting. I changed it back and BooYah!
So i think i am getting closer, but I still can't get install.php to run for wordpress. - egeekAspirantOMFG!
I transcribed localhost:/var/run/mysqld/mysqld.sock from the last test file into wp-config.php so it looks like this./** MySQL hostname */
define('DB_HOST', 'localhost:/var/run/mysqld/mysqld.sock');
and now the wordpress install screen is working. :D :D :D
Hopefully this has solved the issue and had something to do with the syntax/dialogue in use getting PHP to talk to MySQL.
Can't believe i jagged it lol.......
Related Content
NETGEAR Academy
Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology!
Join Us!