Hi there,
I have set up and tested SphinxSe on my server and everything is working fine when I use the command line. However, I am now having difficulties to set up the PT as the connection to MySQL cannot be established through the PT for some reason. I used this code to debug it and see what is causing the problem. First it said that it could not establish connection through /var...mysql.sock. I did not use this directory for mysql.sock so I changed a default directory in PHP.ini from empty to = /tmp/mysql.sock where my socket really is at the moment. After this change I got a notice that LinuxSE prevented connection due to this and that...So I disabled LinuxSE. Now I am gettting this:
Could not connect : Access denied for user 'root'@'localhost' (using password: YES)
This is the code I used to debug it:
<?php
$link = mysql_connect("localhost", "root", "xxxxxx")
or die("Could not connect : " . mysql_error());
print "Connected successfully";
mysql_select_db("mysql") or die("Could not select database");
?>
Many Thanks.
Bob
Hi David,
It fails at the first test saying to check databaseUsername and password. As I am using the same password for my command line My SQL connection and root as a user name without any issues I can't see what the problem is really. So I tried that code to get a bit more information about it.
Many Thanks.
Bob
Hi Bob,
I'm just thinking through the sort of things I would try in this situation. Just having had a look at http://uk.php.net/mysql_connect - do either of the following work:
<?php
$link = mysql_connect("localhost:/tmp/mysql.sock", "root", "xxxxxx")
or die("Could not connect : " . mysql_error());
print "Connected successfully";
mysql_select_db("mysql") or die("Could not select database");
?>
~or just~
<?php
$link = mysql_connect(":/tmp/mysql.sock", "root", "xxxxxx")
or die("Could not connect : " . mysql_error());
print "Connected successfully";
mysql_select_db("mysql") or die("Could not select database");
?>
Cheers,
David
Hi David,
It did not work. So it might not be a socket issue now. This must be something to do with permissions. I am just thinking about the set up. This is how I set the ownership of files in order to make MySQL a bit more secure:
chown -R root /usr/local/mysql
chown -R mysql /usr/local/mysql/var (where the data is)
chgrp -R mysql /usr/local/mysql
Do you think this set up might be causing some problems with connection?
Many Thanks.
Bob
Hi Bob,
Quite possibly. I notice that you are setting the group to "mysql", which means that whatever user PHP is running is (it maybe "apache" or perhaps "deamon") will need to be a member of that group; unless you have world read set on the socket file.
You could test this quickly by temporarily enabling world read access on the file and trying again:
chmod a+r /usr/local/mysql
(a+r means set read access to ALL)
If that works then you know that it is a permissions issue...
Cheers,
David.
David,
I did chmod this directory as suggested but still no luck. Hmmm...Would that affect the group's settings as well? The thing is if I just do all those things including search through the command line I have no problems there whatsovere. So it must be something 'outside' that is causing this. And I simply do not know what it is.
Many Thanks.
Bob
Hi Bob,
Here's a thought. From the command line, set the user to the same user that PHP will be running as:
su apache
(where apache is whatever user PHP is setup to run as on your system)
...and then try accessing MySQL again...(from the command line)
Cheers,
David.
David,
Thanks for that. I am now going to try that hack and see if I can discover some more info about it all. The thing I really do not understand when I try to debug some issues is why MySQL stops with their explanations at : access denied. We need a reason for it not just to be told that access has been denied. I think the whole thing with users and permissions is in a complete mess to be honest. Anyway I will have a go at this and see if it works.
Many Thanks.
Bob
David,
Thanks very much for your support. Is there any quick way to find out which user PHP is running under. I am just doing some reading about it. I had no clue that PHP is also having these user issues as well. Oh well. I did php -i and could see a few user: root entries but I am not sure if that's because I am running as root at the moment.
Many Thanks.
Bob
Hi Bob,
This worked on my test server:
<?php
passthru("whoami");
?>
Cheers,
David.
Hi David,
Thanks for your reply. I have finally discovered what was causing the problem. I re-installed MySQL and tested the PT without a password and it all went through :) I installed phpMyAdmin last night and I got a few warnings in there:
Cannot load mcrypt extension. Please check your PHP configuration.
The mbstring PHP extension was not found and you seem to be using a multibyte charset. Without the mbstring extension phpMyAdmin is unable to split strings correctly and it may result in unexpected results.
So it looks like it's down to PHP not passing the password correctly because of these issues. I now have to find a way to fix PHP and secure MySQL installation. I am not sure why these PHP extensions are not in there as I am running 5.1.6 PHP installed together with my distrubution.
Many Thanks.
Bob
Hi Bob,
Price Tapestry's setup.php is good for diagnosing db connections.
If you browse to:
http://www.example.com/setup.php
...it will then perform the 3 tests. How far does that get?
Cheers,
David.