Skip to content

Commit

Permalink
Got local mysql auth working off cli so no warnign
Browse files Browse the repository at this point in the history
  • Loading branch information
ronnorthrip committed Feb 13, 2024
1 parent 54d7fba commit 7da1cd3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Commands/DBPull.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class DBPull extends Command

protected $local_mysql_auth_echo = '';

protected $local_mysql_auth_file = '';

protected $from = '';

protected $from_lc = '';
Expand Down Expand Up @@ -116,7 +118,8 @@ protected function setup()
$this->local_mysql_user = config('dbpull.local.username', '');
$this->local_mysql_password = config('dbpull.local.password', '');
$this->local_mysql_database = config('dbpull.local.database', '');
$this->local_mysql_auth_echo = "echo -e \"[client]\nuser=$this->local_mysql_password\npassword=$this->local_mysql_database\"";
$this->local_mysql_auth_echo = "echo \"[client]\nuser=$this->local_mysql_user\npassword=$this->local_mysql_password\"";
$this->local_mysql_auth_file = $this->local_pulls_path.'.local.cnf';
$this->remote_ssh = config('dbpull.'.$this->from.'.ssh', '');
$this->remote_mysql_host = config('dbpull.'.$this->from.'.host', '');
$this->remote_mysql_port = config('dbpull.'.$this->from.'.port', '');
Expand Down Expand Up @@ -562,9 +565,8 @@ public function local_flush_pulls_dir()

public function local_sql_import($file)
{
//TODO - this is a hack to get around the mysql auth echo not working
// exec("$this->local_mysql_auth_echo | mysql --defaults-extra-file=/dev/stdin $this->local_mysql_database < ".$this->local_pulls_path.$file);
exec("mysql -u$this->local_mysql_user -p$this->local_mysql_password $this->local_mysql_database < ".$this->local_pulls_path.$file);
exec($this->local_mysql_auth_echo.' > '.$this->local_mysql_auth_file);
exec("mysql --defaults-extra-file=$this->local_mysql_auth_file $this->local_mysql_database < ".$this->local_pulls_path.$file);
}

public function has_old_data()
Expand Down

0 comments on commit 7da1cd3

Please sign in to comment.