在Agile Toolkit中设置mysql端口号

发布于 2024-12-09 23:33:04 字数 2578 浏览 0 评论 0原文

如何在Agile Toolkit中设置mysql连接的端口号?我本地机器中的 mysql 运行在不同的端口 3307 上,我的连接配置应该是什么样的?

我尝试了以下方法,但它不起作用,

$config['dsn']='mysql://atk:password@localhost:3307/atk';

当我尝试数据库测试时,出现以下错误,

C:\xampp\htdocs\atk4.1.2\atk4\lib\DBlite/mysql.php:40 [2] mysql_pconnect() [function.mysql-pconnect]: [2002] No connection could be made because the target machine actively refused it. (trying to connect via tcp://localhost:3306)
C:\xampp\htdocs\atk4.1.2\atk4\lib\DBlite/mysql.php:40 [2] mysql_pconnect() [function.mysql-pconnect]: No connection could be made because the target machine actively refused it. 

SQLException

Database connection failed

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


C:\xampp\htdocs\atk4.1.2\atk4\lib\BaseException.php:37

Stack trace:
C:\xampp\htdocs\atk4.1.2\atk4\lib/BaseException.php :37  SQLException BaseException->collectBasicData(Null, 1, 0) 
C:\xampp\htdocs\atk4.1.2\atk4\lib/SQLException.php :45  SQLException BaseException->__construct("<p>Database connection failed</p><b>MySQL error:</b> <div style='border: 1px solid black'><font color=red>No connection could be...", Null, 1) 
C:\xampp\htdocs\atk4.1.2\atk4\lib/DBlite.php :359  SQLException SQLException->__construct(Null, "Database connection failed") 
C:\xampp\htdocs\atk4.1.2\atk4\lib/DBlite.php :101  gift_project DBlite->fatal("Database connection failed", True) 
C:\xampp\htdocs\atk4.1.2\atk4\lib/ApiCLI.php :276  gift_project DBlite->connect(Array(7)) 
C:\xampp\htdocs\atk4.1.2\page/dbtest.php :7  gift_project ApiCLI->dbConnect() 
C:\xampp\htdocs\atk4.1.2\atk4\lib/AbstractObject.php :129  gift_project_dbtest page_dbtest->init() 
C:\xampp\htdocs\atk4.1.2\atk4\lib/ApiFrontend.php :90  gift_project AbstractObject->add("page_dbtest", "dbtest", "Content") 
C:\xampp\htdocs\atk4.1.2\atk4\lib/ApiWeb.php :305  gift_project ApiFrontend->layout_Content() 
C:\xampp\htdocs\atk4.1.2\atk4\lib/ApiWeb.php :297  gift_project ApiWeb->addLayout("Content") 
C:\xampp\htdocs\atk4.1.2\atk4\lib/ApiWeb.php :182  gift_project ApiWeb->initLayout() 
C:\xampp\htdocs\atk4.1.2/index.php :15  gift_project ApiWeb->main() 

解决方案:以下类型的配置有效,

$config['dsn']=array('type'=>'mysql',
             'hostspec'=>'localhost:3307',
             'username'=>'atk',
             'password'=>'password',
             'database'=>'atk',
             'charset'=>'utf-8');

How do I set a port number for mysql connection in Agile Toolkit? The mysql in my local machine is running in a different port 3307, how should be my connection configuration look like?

I tried the following but it did not work,

$config['dsn']='mysql://atk:password@localhost:3307/atk';

I am getting the following error when I try a db test,

C:\xampp\htdocs\atk4.1.2\atk4\lib\DBlite/mysql.php:40 [2] mysql_pconnect() [function.mysql-pconnect]: [2002] No connection could be made because the target machine actively refused it. (trying to connect via tcp://localhost:3306)
C:\xampp\htdocs\atk4.1.2\atk4\lib\DBlite/mysql.php:40 [2] mysql_pconnect() [function.mysql-pconnect]: No connection could be made because the target machine actively refused it. 

SQLException

Database connection failed

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


C:\xampp\htdocs\atk4.1.2\atk4\lib\BaseException.php:37

Stack trace:
C:\xampp\htdocs\atk4.1.2\atk4\lib/BaseException.php :37  SQLException BaseException->collectBasicData(Null, 1, 0) 
C:\xampp\htdocs\atk4.1.2\atk4\lib/SQLException.php :45  SQLException BaseException->__construct("<p>Database connection failed</p><b>MySQL error:</b> <div style='border: 1px solid black'><font color=red>No connection could be...", Null, 1) 
C:\xampp\htdocs\atk4.1.2\atk4\lib/DBlite.php :359  SQLException SQLException->__construct(Null, "Database connection failed") 
C:\xampp\htdocs\atk4.1.2\atk4\lib/DBlite.php :101  gift_project DBlite->fatal("Database connection failed", True) 
C:\xampp\htdocs\atk4.1.2\atk4\lib/ApiCLI.php :276  gift_project DBlite->connect(Array(7)) 
C:\xampp\htdocs\atk4.1.2\page/dbtest.php :7  gift_project ApiCLI->dbConnect() 
C:\xampp\htdocs\atk4.1.2\atk4\lib/AbstractObject.php :129  gift_project_dbtest page_dbtest->init() 
C:\xampp\htdocs\atk4.1.2\atk4\lib/ApiFrontend.php :90  gift_project AbstractObject->add("page_dbtest", "dbtest", "Content") 
C:\xampp\htdocs\atk4.1.2\atk4\lib/ApiWeb.php :305  gift_project ApiFrontend->layout_Content() 
C:\xampp\htdocs\atk4.1.2\atk4\lib/ApiWeb.php :297  gift_project ApiWeb->addLayout("Content") 
C:\xampp\htdocs\atk4.1.2\atk4\lib/ApiWeb.php :182  gift_project ApiWeb->initLayout() 
C:\xampp\htdocs\atk4.1.2/index.php :15  gift_project ApiWeb->main() 

Solution : The following type of configuration works,

$config['dsn']=array('type'=>'mysql',
             'hostspec'=>'localhost:3307',
             'username'=>'atk',
             'password'=>'password',
             'database'=>'atk',
             'charset'=>'utf-8');

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

很糊涂小朋友 2024-12-16 23:33:04

尝试以下操作

 $config['dsn']=array('type'=>'mysql','username'=>'atk',
 'host'=>'localhost','database'=>'atk','password'=>'password',
 'port'=>3307,'charset'=>'utf-8');

try the following

 $config['dsn']=array('type'=>'mysql','username'=>'atk',
 'host'=>'localhost','database'=>'atk','password'=>'password',
 'port'=>3307,'charset'=>'utf-8');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文