跨多个drupal实例、不同的数据库用户帐户共享数据库表
我安装了多个 drupal 实例,并且希望在所有其他站点之间共享一个实例的用户和会话表。我在 settings.php 文件中放置了正确的前缀 $db_prefix = array( '默认' => 'db1.', '会话' => 'db2.', '用户' => 'db2.', );
Db1 和 db2 有自己的 db 用户帐户。 我还在 settings.php 文件中提供了用户帐户和凭据。 $db_url = 数组( '默认' => 'mysql://user1:密码@localhost/db1', '用户' => 'mysql://user2:密码@localhost/db2', );
但是当drupal访问db2时,它不知道使用db2凭证来访问db2上的用户表。我继续使用默认的。我还尝试在 $db_url 中使用数据库名称和 db2 站点名称而不是“用户”,但没有成功。
有没有办法告诉 drupal 在设置文件中访问 db2 时使用另一个帐户。我知道我可以将 db1 上的 user1 分配给 mysql 中 db2 上的用户表,但如果这可以在 settings.php 中完成,我不想这样做
I have multiple drupal instances install and would like to share the user and session table from one instance across all my other sites.I place the proper prefix in the settings.php file $db_prefix = array(
'default' => 'db1.',
'sessions' => 'db2.',
'users' => 'db2.',
);
Db1 and db2 have its own db user account.
I provide the user acccount and credential in the settings.php file as well.
$db_url = array(
'default' => 'mysql://user1:password@localhost/db1',
'users' => 'mysql://user2:password@localhost/db2',
);
but when drupal is accessing db2, it doesnt know to use the db2 credential to access the user table on db2. I keep on using the default. I also tried using the name of the db and site name of db2 instead of "user" in the $db_url but wasnt successful.
Is there a way of telling drupal to use another account when accessing db2 in the settings file. I know i can just assign user1 on db1 access to the user table on db2 in mysql but would prefer not to if this can be done in settings.php
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不能。
例如,有一些查询像这样连接 {node} 和 {user}:
即使使用不同的数据库也可能会出现问题,并且实际上并不是 $db_prefix 应该使用的。
因此,您有两个选择:
为两个数据库创建一个公共用户。
如果您无法做到这一点(例如,因为您的托管环境在用户和数据库之间具有 1:1 映射),请将它们移至同一数据库但使用不同的前缀。例如“site1_”和“site2_”。
You can not.
There are for example queries which join {node} and {user} like this:
Even using different databases can be problematic and isn't really what the $db_prefix is supposed to be used.
So, you have two options:
Create a common user for both databases.
If you can't do that (for example, because your hosting environment has a 1:1 mapping between users and databases), move them to the same database but use a different prefix. For example 'site1_' and 'site2_'.