Skip to content

Commit 6a512e4

Browse files
authored
Merge pull request #17 from estrma/allow-different-mysql-hostname
Allow different MySQL hostname
2 parents 6e7de3f + 8166205 commit 6a512e4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

config/dbsync.php

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
*/
2828
'username' => env('REMOTE_DATABASE_USERNAME', ''),
2929

30+
/*
31+
* Database host (optional)
32+
*/
33+
'mysqlHostName' => env('REMOTE_DATABASE_MYSQL_HOSTNAME', 'localhost'),
34+
3035
/*
3136
* Database port
3237
*/

src/Console/DbSyncCommand.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ public function handle(): bool
2020
return true;
2121
}
2222

23-
$host = config('dbsync.host');
2423
$useSsh = config('dbsync.useSsh');
2524
$sshUsername = config('dbsync.sshUsername');
2625
$sshPort = config('dbsync.sshPort');
26+
$host = config('dbsync.host');
2727

28+
$mysqlHostName = config('dbsync.mysqlHostName');
2829
$username = config('dbsync.username');
2930
$database = config('dbsync.database');
3031
$port = config('dbsync.port');
@@ -59,7 +60,8 @@ public function handle(): bool
5960
}
6061

6162
if ($useSsh === true) {
62-
exec("ssh $sshUsername@$host -p$sshPort mysqldump -P$port -u$username -p$password $database $ignoreString > $fileName", $output);
63+
echo($mysqlHostName . PHP_EOL);
64+
exec("ssh $sshUsername@$host -p$sshPort mysqldump -P$port -h$mysqlHostName -u$username -p$password $database $ignoreString > $fileName", $output);
6365
} else {
6466
exec("mysqldump -h$host -P$port -u$username -p$password $database $ignoreString $mysqldumpSkipTzUtc --column-statistics=0 > $fileName", $output);
6567
}

0 commit comments

Comments
 (0)