Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
More than one MySQL server on VPS with only one IP requires non-standard ports and it would be nice to have $db_port here - something like this in provision_drupal_settings.tpl.php:
$databases['default']['default'] = array(
'driver' => '<?php print $db_type; ?>',
'database' => '<?php print $db_name; ?>',
'username' => '<?php print $db_user; ?>',
'password' => '<?php print $db_passwd; ?>',
'host' => '<?php print $db_host ?>',
'port' => '<?php print $db_port ?>',
);
$db_url = '<?php print "$db_type://$db_user:$db_passwd@$db_host:$db_port/$db_name"; ?>';
Comments
Comment #1
anarcat CreditAttribution: anarcat commentedThat will not be enough: you'll need to overhaul the frontend (which means the db_server node form and the db_server table schema) so that this can be changed by the user. I'm marking this as minor since it's fairly uncommon to see a mysqld on a different port (why would you do that anyways?).
Comment #2
omega8cc CreditAttribution: omega8cc commentedI had to use MySQL 5.1 on a VPS with stable Debian, so with installed MySQL 5.0.
It was VPS with only one IP and without any chance for second IP (Gandi.net case).
Binding one MySQL to public IP and second to localhost was not an option since
remote replication was used.
Trying to find all places in a code where it should be changed, I have found a few
where $port variable was ready to define and use, but there is more where it is
not used (also in parsing template config.php).
This is not a rocket science issue and of course too specific to be a problem. I had a chance
to better learn some details in provision module.
It seems, for example, when you have MySQL listening on a public IP and not localhost,
but both Aegir and MySQL will be on the same IP, Provision will create users in MySQL
with privileges to access from localhost and not public IP. Kind of bug, it seems,
but will report it when confirm if this still exist in 6.x (had this issue under 5.x)
~Grace
Comment #3
anarcat CreditAttribution: anarcat commentedFeel free to provide a patch for this functionality.
(as for the grant issue, the behavior likely didn't change in the d6 upgrade, so may as well open a bug about this if you think it's one)
Comment #4
starbow CreditAttribution: starbow commentedHas there been any progress on this? UC Berkeley hosts db accounts separate ports, one per account. So, for me it is a major issue :)
Comment #5
starbow CreditAttribution: starbow commentedOk, to fix this, in provision_mysql.drush.inc, in the function provision_mysql_drush_init()
replace:
drush_set_default('master_db_host', $db['host']);
drush_set_default('db_host', $db['host']);
with:
$host = $db['host'];
if ($db['port']) {
$host .= ':'. $db['port'];
}
drush_set_default('master_db_host', $host);
drush_set_default('db_host', $host);
Comment #6
starbow CreditAttribution: starbow commentedOf course, it is not that simple.
The next bit I found is in provision_drupal_settings.tpl.php.
The db_host needs to be urldecoded in the $db_url, or the colon gets munged.
Here is one way to do it:
More as I figure it out.
Comment #7
starbow CreditAttribution: starbow commentedOk, this is getting a little ugly. Here is the code to get backups working with the port in the host, from db_server/backup.provision.inc/drush_provision_mysql_pre_provision_backup
And, of course, we need to do almost the same thing in db_server/provision_mysql.drush.inc/_provision_mysql_import_dump
Comment #8
starbow CreditAttribution: starbow commentedAnd, of course, to clone you need backup and import, so
platform/drupal/import_6.inc
Comment #9
Anonymous (not verified) CreditAttribution: Anonymous commentedAre you able to supply a proper patch so that we can test it?
Cheers!
Comment #10
starbow CreditAttribution: starbow commentedJust to be clear, I am not actually recommending this path. It would be better to break the db port out into it's own UI field and cached option. This is the quick and dirty approach, and it has only one advantage, and that is that it seems to be working.
Comment #11
adrian CreditAttribution: adrian commentedThis will help with that :
#836136: Simplify ports support.
Comment #12
adrian CreditAttribution: adrian commentedThis is partially implemented in HEAD now.
The front end is there, all that's remaining is adding the value to the mysql db credentials.
Comment #13
adrian CreditAttribution: adrian commentedCommitted to HEAD.
you configure it on the server, and the configs will generate for it
Comment #14
omega8cc CreditAttribution: omega8cc commentedI tested it now with current head.
1. The verify task fails after I changed port to 3308 at node/2/edit (expected).
2. Then I changed the port in the MySQL server config and restarted it.
3. Now went to settings.php for hostmaster and changed port to 3308 manually.
4. Then re-verified the server and all platforms.
5. Now tried to re-verify the d6 site and the task failed.
It seems it doesn't rewrite settings.php properly (because it doesn't rewrite also drushrc.php) with the new port.
Comment #15
omega8cc CreditAttribution: omega8cc commentedFrom IRC #aegir on freenode:
So, by design it is expected to work only on install, with added
--db_port=
as an argument.However it doesn't work for me.
The command
sh install.sh.txt aegir.example.com --http_service_type='nginx' --db_port='3308' -d
fails with:The database server listens of course on the port 3308.
Comment #16
bwood CreditAttribution: bwood commentedI took a quick look at this in alpha12 a few days ago and was going down this path:
The reason I added 'aegir_db_host' is that without that install.hostmaster, seems to be assuming that mysql will be running locally on the webserver, which is not the case for me.
$data['master_db'] is the db url that the frontend (hostmaster) server uses (I think).
If I want to use --backend-only, does the webserver I'm setting up need $data['master_db']? (I think that $data['master_db'] might need to go in one of the drush alias files created on the backend (webserver).)
Does the backend (webserver) need to connect to the frontend (hostmaster)'s database? (I think that it probably does not need to...)
I'll be coming back to this early next week.
(I'm trying to step through the new code using eclipse + xdebug working on my ubuntu 10.04 laptop. I've got it working basically, but if there are any notes on the best way to debug drush/provision that you can point me too, let me know!)
Comment #17
John_Buehrer CreditAttribution: John_Buehrer commentedAny luck? I also got this far in the code before seeing your post, but I still get the dreaded "Fatal error: Call to a member function quote() on a non-object", meaning the database connection didn't work.
In my use case, I only need to change the port, not the host, as MAMP picks its own port number and I don't want to change it for several reasons. I'm surprised that an assumed port number would be hardwired into an install script, especially since "db_port" already appears deep down in some included code.
(Based on the error message, it looks like there are two errors here:
1. the wrong sort of mysql db connection parameters.
2. the script itself is not recovering from error #1.
It seems the script has support to show a diagnostic about the database problem, but that logic is wrong and gives the "object-oriented" error. Can that be fixed by someone familiar with it? Then the rest of us can fix our own database connections as we see fit.)
Comment #18
Steven Jones CreditAttribution: Steven Jones commentedI'm fairly certain that Aegir now supports this.
Comment #20
cweagansRelated: #2069387: Support nonstandard ports on hostmaster-install command