0

` I tried a lot and didnt any kind of answer. I think it is not work

I wanna make migration from php but this is not work and when I execute sql files there is no error but my DB doesn`t change

This command didnt work : $command = sprintf('mysql -u %s -p %s -h %s -D %s < %s', DB_USER, DB_PASSWORD, DB_HOST, DB_NAME, $file);

define('DB_HOST', '127.0.0.1');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_NAME', 'test');
define('DB_TABLE_VERSIONS', 'versions');

$command = sprintf('mysql -u %s -p %s -h %s -D %s < %s', DB_USER, DB_PASSWORD, DB_HOST, DB_NAME, $file);
shell_exec($command);
bassxzero
  • 4,838
  • 22
  • 34
  • You have forgot to give file path ex : shell_exec($command . '/shellexec.sql'); – manu Jun 16 '19 at 20:43
  • 3
    Possible duplicate of [Running MySQL \*.sql files in PHP](https://stackoverflow.com/questions/4027769/running-mysql-sql-files-in-php) – manu Jun 16 '19 at 20:45
  • If you use the `-p` option there must not be any blank space after the option letter. Additionally, you need to capture the echo and return value of shell_exec to better undestand the problem. As last, using plain password in shell_exec as **serious** security implciations. – salvatore Jun 16 '19 at 20:49

0 Answers0