我昨天安装了agiletoolkit,因为我喜欢他们提供的关于GUI 开发的外观。
不幸的是,我无法连接到我的 MySQL 数据库。
SQLException
Database connection failed
MySQL error:
php_network_getaddresses: getaddrinfo failed: No such host is known.
在我的 config.php 中,我已经指定了
$config['dsn']='mysql://root:root:3307@localhost/agiletoolkit_examples';
我查看了 DBlite.php 并告诉该文件转储一个名为 $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)
这对我来说不合适。. . 它分配“root”作为我的端口。
谢谢,贝瑞,你的迅速反应。
我第一次尝试...
$config['dsn']='mysql://root:root@localhost:3307/agiletoolkit_examples';
但出现以下错误:
SQLException
Database connection failed
MySQL error:
No connection could be made because the target machine actively refused it.
以及 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)
...看起来更好的映射,但不起作用。
因此,我参考了文档并发现了这一点:
$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';
和这个(通过数组定义访问):
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');
我不认为我安装 mysql 有什么问题,因为 codeIgniter、yii 和我所有的应用程序都可以正常工作。
有没有遇到过类似问题的用户?
谢谢你的帮助