0

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

romaninsh
  • 10,606
  • 4
  • 50
  • 70

2 Answers2

1

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

Community
  • 1
  • 1
romaninsh
  • 10,606
  • 4
  • 50
  • 70
0

$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>"
Berry Langerak
  • 18,561
  • 4
  • 45
  • 58
  • I would have to agree with you, but that doesn't seem to be the case with ATK. Check their documentation [link](http://agiletoolkit.org/learn/install/db) – Mike Mullin Oct 19 '11 at 07:36
  • @MikeMullin So they made an error in their documentation? These things happen. See how a little lower on the page, they write the portnumber after the host? Have you tried it? – Berry Langerak Oct 19 '11 at 07:46
  • There is a problem in their MySQL driver file \agiletoolkit\atk4\lib\DBlite\mysql.php, port is not being used in the mysql_connect() function ... $this->handle=mysql_connect( $this->settings['hostspec'], $this->settings['username'], $this->settings['password'], true); So, I added .':'.$this->settings['port'] after the HOSTSPEC param and it seems to work now. I dropped a message in their "contact Us" section, if they read that? Who should I tell about this? – Mike Mullin Oct 19 '11 at 08:58
  • @MikeMullin I've never used Agiletoolkit, so I wouldn't know. I just figured the DSN syntax was incorrect :) – Berry Langerak Oct 19 '11 at 11:56