Welcome Guest, Not a member yet? Register   Sign In
mysql sock error using code igniter
#1

[eluser]kingconnections[/eluser]
I am moving this a site over for a client and it uses codeigniter. I am a complete noob to this framework. I got everything copied over and all. I changed the database info in the database.php file. But I get this mysql can not connect to socket error.

Can't connect to local MySQL server through socket '/usr/local/mysql-5.0/data/mysql.sock' (2)


If I use the standard coding skills I am able to connect to the db fine. ie


$conn = mysql_connect('host.sever.net','user1','User1');
if (!conn) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';

if (!mysql_select_db("test")) {
echo "Unable to select mydbname: " . mysql_error();
exit;
}

$sql = "SELECT email
FROM user
";

$result = mysql_query($sql);

if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}

if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}

// While a row of data exists, put that row in $row as an associative array
// Note: If you're expecting just one row, no need to use a loop
// Note: If you put extract($row); inside the following loop, you'll
// then create $userid, $fullname, and $userstatus
while ($row = mysql_fetch_assoc($result)) {
echo $row["email"];
echo "<br>";
}

mysql_free_result($result);


mysql_close($conn);

Any ideas? Any help would be great!!!
#2

[eluser]thurting[/eluser]
I would check your config file again. Also, make sure the DB allows connections from whatever server you are connecting from (though if you can connect using non CI methods this shouldn't be an issue).
#3

[eluser]llbbl[/eluser]
this not a CI issue its something wrong with your mysql configuration.
#4

[eluser]kingconnections[/eluser]
So is there any way to change code igniter to use the standart mysql functions instead of a sock based call? Like I said, the standard way works fine, this just happened when I put on codeigniter.

Thanks for the replies!!!!
#5

[eluser]llbbl[/eluser]
Codeigniter uses the standard methods...

Try looking at the CI db code? Try searching google for your problem. Sock errors are a result when you tried to start mysql when its already running or if your mysql configuration (my.cnf) is fubar or your didn't start mysql properly or you are running more than one copy of mysql or something else like that...

This will take someone who knows about mysql and knows linux administration to poke around on your system till they figure it out. It is not as simple as download purple widget A and will fix your problem.
#6

[eluser]kingconnections[/eluser]
I understand about the socket error being a mysql config issue. But that doesn't really make since in this scenerio where I can connect and query the db using the coded published aboved, but not the codeigniter connections. If it really was a mysql issue they I shouldn't be able to write a sample script like the one I provided and have it work right? Thanks for all the help.
#7

[eluser]kingconnections[/eluser]
It almost seems like it is trying to use local socket. I am using a remote db, would that matter? Where can I see what my connection string is for this?
#8

[eluser]llbbl[/eluser]
In the /system/application/config/database.php file did you set the hostname correctly?

Is the database driver mysql?

Code:
$db['default']['dbdriver'] = "mysql";
#9

[eluser]kingconnections[/eluser]
yep both are set correctly. HMMM wierd.
#10

[eluser]kingconnections[/eluser]
Hmm just got off the phone with godaddy. Seems for some reason it is trying to use local connection instead of the remote one. Anyone got any ideas? Is there any debugging in this framework for these types of issues?




Theme © iAndrew 2016 - Forum software by © MyBB