Agiletoolkit can't connect to database

577 Views Asked by At

I ,installed agiletoolkit yesterday because I like the look of what they offer regarding GUI development.

Unfortunately I could not connect to my MySQL databases.

SQLException

Database connection failed
MySQL error:
php_network_getaddresses: getaddrinfo failed: No such host is known. 

In my config.php I have sepcified

$config['dsn']='mysql://root:root:3307@localhost/agiletoolkit_examples';

I looked at DBlite.php and told that file to dump a variable called $dsn_a . . .

array
  'database' => string 'agiletoolkit_examples' (length=21)
  'body' => string 'root:root:3307@localhost' (length=24)
  'type' => string 'mysql' (length=5)
  'port' => string 'root' (length=4)
  'hostspec' => string 'root' (length=4)

This doesn't look right to me . . . it's assigning "root" as my port.


Thanks, Berry, for your swift response.

I had first tried ...

$config['dsn']='mysql://root:root@localhost:3307/agiletoolkit_examples';

but got the following error:

SQLException

Database connection failed
MySQL error:
No connection could be made because the target machine actively refused it.

and the following output of var_dump:

dsn_a:

array
  'database' => string 'agiletoolkit_examples' (length=21)
  'body' => string 'root:root@localhost:3307' (length=24)
  'type' => string 'mysql' (length=5)
  'port' => string '3307' (length=4)
  'hostspec' => string 'localhost' (length=9)
  'transport' => string '' (length=0)
  'password' => string 'root' (length=4)
  'username' => string 'root' (length=4)

... which looks better mapped, but does not work.

So, I referred to the documentation and found this:

$config['dsn']='mysql://user:password@localhost/dbname';

// define port:
// $config['dsn']='mysql://user:password:8888@localhost/dbname';

// through socket
// $config['dsn']='mysql://user:password:/tmp/sock@localhost/dbname';

and this (Defining Access through an Array):

If the DSN string is impossible to define - for example, if your password contains the '@' character - then this alternative format is preferred: 

$config['dsn']=array(
     'hostspec'=>'localhost:1234',
     'username'=>'dbuser',
     'password'=>'secret' );
// Arguments passed to mysql_connect as 
// mysql_connect('localhost:1234','dbuser','secret');

I don't think there's anything wrong with my installation of mysql because codeIgniter, yii and all my apps work fine.

Are there any users out there who have had similar problems?

Thanks for your help

2

There are 2 best solutions below

4
On

$config['dsn']='mysql://root:root:3307@localhost/agiletoolkit_examples';

I don't think the port should be written there. Try the following instead:

$config['dsn']='mysql://root:root@localhost:3307/agiletoolkit_examples';

To be more verbose, the correct syntax of a Data Connection String is the following:

"<driver>://<username>:<password>@<host>:<port>/<database>"
0
On

There is a bug in SQL driver. Here is question and work-around: Setting mysql port number in agile toolkit

Bug-report and fix: https://github.com/atk4/atk4/issues/27