如何在Drupal中指定MySQL的端口?
我需要将 MySQL 的默认端口从 3306 更改为其他端口(假设为 3300)
我已在 sites/default.settings.php 中编辑了setting.php 并进行了更改
$db_url['default'] = 'mysqli://root:password@localhost/dbname'; TO
$db_url['default'] = 'mysqli://root:password@localhost:3300/dbname';
但这不起作用! 如何更改默认端口?
I need to change the default port of MySQL from 3306 to something else (let us say 3300)
I have edited setting.php in sites/default.settings.php and changed
$db_url['default'] = 'mysqli://root:password@localhost/dbname'; TO
$db_url['default'] = 'mysqli://root:password@localhost:3300/dbname';
but this didn't work!
How can I change the default port?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您是否尝试过清除缓存?如果 Drupal 从其他地方提取数据,则不会识别该更改。
我认为您可以在 yoursite.com/admin/settings/performance 上进行操作
Have you tried clearing the cache? Drupal won't recognize the change if its pulling the data from elsewhere.
I think you can do it at yoursite.com/admin/settings/performance
$db_url['default'] = 'mysqli://root:password@localhost:3300/dbname';
应该可以工作。至少在几个项目中是这样的。你可能还有另一个错误。$db_url['default'] = 'mysqli://root:password@localhost:3300/dbname';
should work. At least it does here, in several projects. You might have another bug.您是否还重新配置了 mysql 服务器以使用 3300 端口?
Have you also reconfigured your mysql server to work with the 3300 port?
确保您正在编辑正确的文件。 site/default/settings.php 或sites/mysite.com/settings.php。您根本不应该编辑“default.settings.php”文件。如果你可能是的话,从你的问题来看有点不清楚。
Make sure you're editing the correct file. Either sites/default/settings.php or sites/mysite.com/settings.php. You shouldn't be editing the 'default.settings.php' file at all. It's a little unclear from your question if you might be.
MySQL客户端库在使用
localhost
时使用套接字连接,因此忽略端口参数并使用默认设置。为了解决这个问题,您应该使用
127.0.0.1
而不是“localhost”更改
为
(如果其他人偶然发现此问题,请恢复此操作)
MySQL client library uses socket connection when using
localhost
, thus ignoring the port parameter and using the default setting.In order to fix this you should use
127.0.0.1
instead of "localhost"change
to
(Ressurecting this in case someone else stumbles on this issue)