Welcome Guest, Not a member yet? Register   Sign In
MySql Connection Fail [resolved]
#1

[eluser]koringa[/eluser]
Hello Guys,

I use MacOS and trying to connect my project to the MySQL database using the Code Iginiter. I can connect from the command line or any others program, for example Sequel Pro for Mysql Database Administration, that is, my database works and is running normally.

In my autoload.php I set point to autoload database.

Code:
$autoload['libraries'] = array("database","session");

Below is my database.php

Code:
$active_group = "default";
$active_record = TRUE;

$db['default'][ 'hostname'] = "localhost";
$db['default'][ 'username'] = "root";
$db['default'][ 'password'] = "****";
$db['default'][ 'database'] = "sitesp";
$db['default'][ 'dbdriver'] = "mysql";
$db['default'][ 'dbprefix'] = "";
$db['default'][ 'pconnect'] = TRUE;
$db['default'][ 'db_debug'] = TRUE;
$db['default'][ 'cache_on'] = FALSE;
$db['default'][ 'cached'] = "";
$db['default'][ 'CHAR_SET'] = "utf8";
$db['default'][ 'dbcollat'] = "utf8_general_ci";

The database "sitesp" was created, of course.

Just get the message:

A Database Error Occurred
Unable to select the specified database: sitesp


If anyone has been there, will help a lot.

Thank you and anything I can, post here too.
[]
Thanks
#2

[eluser]jedd[/eluser]
Hi koringa and welcome to the CI forums.


Quote:I can connect from the command line or any others program, for example Sequel Pro for Mysql Database Administration, that is, my database works and is running normally.

Do you connect, at the commandline, using root, or a normal user account?

You should not be using root (as specified in your config.php above) as it's a touch insecure. Create an account for this app, with a different password, etc.

For the time, try this:

Code:
$   mysql  -u root -h localhost -p sitesp

And confirm you can still connect using your credentials.

I'm not sure how OSX works with local connections, but on some *nix's MySQL will connect through sockets rather than through TCP, which can be confusing because MySQL permissions often include the originating host (name or IP). In any case, the above command line might give some more insight into the nature of the problem.
#3

[eluser]wabu[/eluser]
Can you (re-)confirm that the database name you specified is correct?
#4

[eluser]koringa[/eluser]
I'm at work and my Mac at home, but certainly a problem in MacOS as jedd said, as tested here in Windows with the same settings as my project and it worked. I have to check why the error occurs.

wabu, yes, the database is correct.
#5

[eluser]koringa[/eluser]
jedd,

Resolved as follows:

I edited my .cnf and put the link to the sock, which in my case is

socket = / Applications / MAMP / tmp / mysql / mysql.sock

Thank you all
[]'s




Theme © iAndrew 2016 - Forum software by © MyBB