Drush sql-create --db-su doesn't work with empty root passwords
The crux is drush doesn't pick up the super user from the CLI, using --db-su, unless there is a ~/.my.cnf | |
nor does it pick it up from the alias file at all. | |
My environment is a Mac with Mountain Lion MYSQL install using Homebrew | |
mysql --version: | |
Ver 14.14 Distrib 5.6.19, for osx10.9 (x86_64) | |
php --version | |
PHP 5.4.30 (cli) (built: Jul 29 2014 23:43:29) | |
Copyright (c) 1997-2014 The PHP Group | |
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies | |
drush --version | |
Drush Version : 7.0-dev | |
lstest commit: 763fad5316607f09c6321584f2831efd120a5b19 (something after 7.0.0-alpha7) | |
Alias file: | |
<?php | |
$aliases['test'] = array( | |
'uri' => 'http://localhost/test.local', | |
'root' => '/var/www/test', | |
'databases' => array( | |
'default' => array( | |
'default' => array( | |
'driver' => mysql, | |
'username' => 'test_user', | |
'password' => 'test_pass', | |
'port' => 3306, | |
'host' => localhost, | |
'database' => testdb, | |
), | |
), | |
), | |
); | |
$drush sa @test --with-db | |
RESULT: | |
$aliases["test"] = array ( | |
'uri' => 'http://localhost/test.local', | |
'root' => '/var/www/test', | |
'databases' => | |
array ( | |
'default' => | |
array ( | |
'default' => | |
array ( | |
'driver' => 'mysql', | |
'username' => 'test_user', | |
'password' => 'test_pass', | |
'port' => 3306, | |
'host' => 'localhost', | |
'database' => 'testdb', | |
), | |
), | |
), | |
'#file' => '/Users/jdtaylor/.drush/test.aliases.drushrc.php', | |
'#name' => 'test', | |
); | |
cmd$ drush @test sql-create -y -v -d | |
RESULT: | |
Loaded alias @test from file /Users/jdtaylor/.drush/test.aliases.drushrc.php [0.48 sec, 1.91 MB] [notice] | |
Cache HIT cid: 7.0-dev-commandfiles-0-c36ec6c9d3c715f83d414d8ba6f2e918 [0.48 sec, 1.97 MB] [debug] | |
Bootstrap to phase 0. [0.54 sec, 5.69 MB] [bootstrap] | |
Bootstrap to phase 0. [0.54 sec, 5.7 MB] [bootstrap] | |
Found command: sql-create (commandfile=sql) [0.54 sec, 5.7 MB] [bootstrap] | |
Calling hook drush_sql_create [0.54 sec, 5.74 MB] [debug] | |
Creating database testdb. Any possible existing database will be dropped! | |
Do you really want to continue? (y/n): y | |
sql-query: DROP DATABASE IF EXISTS testdb; CREATE DATABASE testdb /*!40100 DEFAULT CHARACTER SET utf8 */; [0.98 sec, 5.82 MB] [status] | |
Executing: mysql --defaults-extra-file=/private/tmp/drush_cksvsn --database=information_schema --host=localhost --port=3306 --silent < /private/tmp/drush_I8ZVfN | |
ERROR 1045 (28000): Access denied for user 'test_user'@'localhost' (using password: YES) | |
Returned from hook drush_sql_create [1.13 sec, 5.82 MB] [debug] | |
Command dispatch complete [1.13 sec, 5.79 MB] | |
cmd$ drush @test sql-create -y -v -d --db-su=root | |
RESULT: | |
Starting Drush preflight. [0.01 sec, 1.9 MB] [preflight] | |
Loaded alias @test from file /Users/jdtaylor/.drush/test.aliases.drushrc.php [0.91 sec, 1.91 MB] [notice] | |
Cache HIT cid: 7.0-dev-commandfiles-0-c36ec6c9d3c715f83d414d8ba6f2e918 [0.92 sec, 1.97 MB] [debug] | |
Bootstrap to phase 0. [1.14 sec, 5.69 MB] [bootstrap] | |
Bootstrap to phase 0. [1.14 sec, 5.7 MB] [bootstrap] | |
Found command: sql-create (commandfile=sql) [1.14 sec, 5.7 MB] [bootstrap] | |
Calling hook drush_sql_create [1.14 sec, 5.74 MB] [debug] | |
Creating database testdb. Any possible existing database will be dropped! | |
Do you really want to continue? (y/n): y | |
sql-query: DROP DATABASE IF EXISTS testdb; CREATE DATABASE testdb /*!40100 DEFAULT CHARACTER SET utf8 */; GRANT ALL PRIVILEGES ON testdb.* TO 'test_user'@'localhost' IDENTIFIED BY 'test_pass';[status] | |
FLUSH PRIVILEGES; [1.17 sec, 5.82 MB] | |
Executing: mysql --database=information_schema --host=localhost --port=3306 --silent < /private/tmp/drush_TE5O5H | |
ERROR 1044 (42000) at line 1: Access denied for user ''@'localhost' to database 'testdb' | |
Returned from hook drush_sql_create [1.23 sec, 5.82 MB] [debug] | |
Command dispatch complete [1.23 sec, 5.79 MB] | |
alias file: | |
<?php | |
$aliases['test'] = array( | |
'db-su' => 'root', | |
'db-su-pw' => '', | |
'uri' => 'http://localhost/test.local', | |
'root' => '/var/www/test', | |
'databases' => array( | |
'default' => array( | |
'default' => array( | |
'driver' => mysql, | |
'username' => 'test_user', | |
'password' => 'test_pass', | |
'port' => 3306, | |
'host' => localhost, | |
'database' => testdb, | |
), | |
), | |
), | |
); | |
cmd: drush @test sql-create -y -v -d | |
RESULT: | |
Starting Drush preflight. [0.01 sec, 1.9 MB] [preflight] | |
Loaded alias @test from file /Users/jdtaylor/.drush/test.aliases.drushrc.php [0.47 sec, 1.91 MB] [notice] | |
Cache HIT cid: 7.0-dev-commandfiles-0-c36ec6c9d3c715f83d414d8ba6f2e918 [0.47 sec, 1.97 MB] [debug] | |
Bootstrap to phase 0. [0.52 sec, 5.69 MB] [bootstrap] | |
Bootstrap to phase 0. [0.52 sec, 5.7 MB] [bootstrap] | |
Found command: sql-create (commandfile=sql) [0.52 sec, 5.7 MB] [bootstrap] | |
Calling hook drush_sql_create [0.52 sec, 5.74 MB] [debug] | |
Creating database testdb. Any possible existing database will be dropped! | |
Do you really want to continue? (y/n): y | |
sql-query: DROP DATABASE IF EXISTS testdb; CREATE DATABASE testdb /*!40100 DEFAULT CHARACTER SET utf8 */; GRANT ALL PRIVILEGES ON testdb.* TO 'test_user'@'localhost' IDENTIFIED BY 'test_pass';[status] | |
FLUSH PRIVILEGES; [0.53 sec, 5.82 MB] | |
Executing: mysql --database=information_schema --host=localhost --port=3306 --silent < /private/tmp/drush_YT2rHB | |
ERROR 1044 (42000) at line 1: Access denied for user ''@'localhost' to database 'testdb' | |
Returned from hook drush_sql_create [0.54 sec, 5.82 MB] [debug] | |
Command dispatch complete [0.54 sec, 5.79 MB] | |
With ~/.my.cnf: | |
[mysql] | |
user = root | |
password = | |
[client] | |
user = root | |
password = | |
Alias File: | |
<?php | |
$aliases['test'] = array( | |
'uri' => 'http://localhost/test.local', | |
'root' => '/var/www/test', | |
'databases' => array( | |
'default' => array( | |
'default' => array( | |
'driver' => mysql, | |
'username' => 'test_user', | |
'password' => 'test_pass', | |
'port' => 3306, | |
'host' => localhost, | |
'database' => testdb, | |
), | |
), | |
), | |
); | |
cmd: drush @test sql-create -y -v -d | |
RESULT: | |
Starting Drush preflight. [0.01 sec, 1.9 MB] [preflight] | |
Loaded alias @test from file /Users/jdtaylor/.drush/test.aliases.drushrc.php [0.47 sec, 1.91 MB] [notice] | |
Cache HIT cid: 7.0-dev-commandfiles-0-c36ec6c9d3c715f83d414d8ba6f2e918 [0.48 sec, 1.97 MB] [debug] | |
Bootstrap to phase 0. [0.53 sec, 5.69 MB] [bootstrap] | |
Bootstrap to phase 0. [0.53 sec, 5.7 MB] [bootstrap] | |
Found command: sql-create (commandfile=sql) [0.53 sec, 5.7 MB] [bootstrap] | |
Calling hook drush_sql_create [0.53 sec, 5.74 MB] [debug] | |
Creating database testdb. Any possible existing database will be dropped! | |
Do you really want to continue? (y/n): y | |
sql-query: DROP DATABASE IF EXISTS testdb; CREATE DATABASE testdb /*!40100 DEFAULT CHARACTER SET utf8 */; [0.54 sec, 5.82 MB] [status] | |
Executing: mysql --defaults-extra-file=/private/tmp/drush_g4Ch1f --database=information_schema --host=localhost --port=3306 --silent < /private/tmp/drush_ib72Xu | |
Returned from hook drush_sql_create [0.94 sec, 5.82 MB] [debug] | |
Command dispatch complete [0.94 sec, 5.79 MB] | |
cmd: drush @test sql-create -y -v -d --db-su=root | |
RESULT: | |
Starting Drush preflight. [0.01 sec, 1.9 MB] [preflight] | |
Loaded alias @test from file /Users/jdtaylor/.drush/test.aliases.drushrc.php [0.48 sec, 1.91 MB] [notice] | |
Cache HIT cid: 7.0-dev-commandfiles-0-c36ec6c9d3c715f83d414d8ba6f2e918 [0.49 sec, 1.97 MB] [debug] | |
Bootstrap to phase 0. [0.54 sec, 5.69 MB] [bootstrap] | |
Bootstrap to phase 0. [0.54 sec, 5.7 MB] [bootstrap] | |
Found command: sql-create (commandfile=sql) [0.54 sec, 5.7 MB] [bootstrap] | |
Calling hook drush_sql_create [0.54 sec, 5.74 MB] [debug] | |
Creating database testdb. Any possible existing database will be dropped! | |
Do you really want to continue? (y/n): y | |
sql-query: DROP DATABASE IF EXISTS testdb; CREATE DATABASE testdb /*!40100 DEFAULT CHARACTER SET utf8 */; GRANT ALL PRIVILEGES ON testdb.* TO 'test_user'@'localhost' IDENTIFIED BY 'test_pass';[status] | |
FLUSH PRIVILEGES; [0.54 sec, 5.82 MB] | |
Executing: mysql --database=information_schema --host=localhost --port=3306 --silent < /private/tmp/drush_it8bfU | |
Returned from hook drush_sql_create [0.58 sec, 5.82 MB] [debug] | |
Command dispatch complete [0.58 sec, 5.79 MB] | |
alias file: | |
<?php | |
$aliases['test'] = array( | |
'db-su' => 'root', | |
'db-su-pw' => '', | |
'uri' => 'http://localhost/test.local', | |
'root' => '/var/www/test', | |
'databases' => array( | |
'default' => array( | |
'default' => array( | |
'driver' => mysql, | |
'username' => 'test_user', | |
'password' => 'test_pass', | |
'port' => 3306, | |
'host' => localhost, | |
'database' => testdb, | |
), | |
), | |
), | |
); | |
cmd: drush @test sql-create -y -v -d --db-su=root | |
RESULT: | |
Starting Drush preflight. [0.01 sec, 1.9 MB] [preflight] | |
Loaded alias @test from file /Users/jdtaylor/.drush/test.aliases.drushrc.php [0.47 sec, 1.91 MB] [notice] | |
Cache HIT cid: 7.0-dev-commandfiles-0-c36ec6c9d3c715f83d414d8ba6f2e918 [0.48 sec, 1.97 MB] [debug] | |
Bootstrap to phase 0. [0.53 sec, 5.69 MB] [bootstrap] | |
Bootstrap to phase 0. [0.53 sec, 5.7 MB] [bootstrap] | |
Found command: sql-create (commandfile=sql) [0.53 sec, 5.7 MB] [bootstrap] | |
Calling hook drush_sql_create [0.53 sec, 5.74 MB] [debug] | |
Creating database testdb. Any possible existing database will be dropped! | |
Do you really want to continue? (y/n): y | |
sql-query: DROP DATABASE IF EXISTS testdb; CREATE DATABASE testdb /*!40100 DEFAULT CHARACTER SET utf8 */; GRANT ALL PRIVILEGES ON testdb.* TO 'test_user'@'localhost' IDENTIFIED BY 'test_pass';[status] | |
FLUSH PRIVILEGES; [0.54 sec, 5.82 MB] | |
Executing: mysql --database=information_schema --host=localhost --port=3306 --silent < /private/tmp/drush_UlZHrK | |
Returned from hook drush_sql_create [0.55 sec, 5.82 MB] [debug] | |
Command dispatch complete [0.55 sec, 5.8 MB] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment