File tree 3 files changed +19
-1
lines changed
3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,12 @@ To specify a different local database connection:
72
72
LOCAL_TARGET_CONNECTION=different_mysql_connection
73
73
```
74
74
75
+ Set the mysql command path:
76
+
77
+ ```
78
+ LOCAL_MYSQL_PATH=/usr/bin/mysql
79
+ ```
80
+
75
81
For only mysqldump:
76
82
```
77
83
REMOTE_MYSQLDUMP_SKIP_TZ_UTC=true
Original file line number Diff line number Diff line change 68
68
'targetConnection ' => env ('LOCAL_TARGET_CONNECTION ' , 'mysql ' ),
69
69
70
70
'mysqldumpSkipTzUtc ' => env ('REMOTE_MYSQLDUMP_SKIP_TZ_UTC ' , false ),
71
+
72
+ 'localMysqlPath ' => env ('LOCAL_MYSQL_PATH ' , '/usr/local/bin/mysql ' ),
71
73
];
Original file line number Diff line number Diff line change @@ -37,6 +37,13 @@ public function handle(): bool
37
37
$ mysqldumpSkipTzUtc = config ('dbsync.mysqldumpSkipTzUtc ' ) ? '--skip-tz-utc ' : '' ;
38
38
39
39
$ targetConnection = config ('dbsync.targetConnection ' );
40
+
41
+ $ localUsername = config ('database.connections.mysql.username ' );
42
+ $ localPassword = config ('database.connections.mysql.password ' );
43
+ $ localHostname = config ('database.connections.mysql.host ' );
44
+ $ localPort = config ('database.connections.mysql.port ' );
45
+ $ localDatabase = config ('database.connections.mysql.database ' );
46
+ $ localMysqlPath = config ('dbsync.localMysqlPath ' );
40
47
41
48
if (empty ($ host ) || empty ($ username ) || empty ($ database )) {
42
49
$ this ->error ('DB credentials not set, have you published the config and set ENV variables? ' );
@@ -60,7 +67,10 @@ public function handle(): bool
60
67
$ this ->comment (implode (PHP_EOL , $ output ));
61
68
62
69
if ($ importSqlFile === true ) {
63
- DB ::connection ($ targetConnection )->unprepared (file_get_contents (base_path ($ fileName )));
70
+ $ command = $ localPassword
71
+ ? "$ localMysqlPath -u $ localUsername -h $ localHostname -p $ localPassword -P $ localPort $ localDatabase < $ fileName "
72
+ : "$ localMysqlPath -u $ localUsername -h $ localHostname -P $ localPort $ localDatabase < $ fileName " ;
73
+ exec ($ command , $ output );
64
74
}
65
75
66
76
if ($ removeFileAfterImport === true ) {
You can’t perform that action at this time.
0 commit comments