We should patch mysql_install_db to add -p to the second mysqladmin line since setting the password in the first one requires a password in order to run the second one.. I swear i submitted a patch before... Reproducible: Always Steps to Reproduce: 1. 2. 3.
you did submit a patch, and we rejected it, just like upstream did. it does not always require a -p on the second mysqladmin line. it depends on the context you are connecting from (which in turn depends on how your machine is configured). the message from mysqladmin is: 1. mysqladmin -u root -h $hostname password 'new-password' 2. mysqladmin -u root password 'new-password' If mysql resolves your connecting IP back to the hostname you specified in #1, then it requires a password for operation #2. If it resolves to a different hostname, then it does not require a password in #2. The same holds true if you switch the order of the commands around. The source of this problem is that machines have $hostname as 'localhost', or if they put their own hostname in /etc/hosts as 127.0.0.1. I'd consider machines where that is the case to be misconfigured.
*** Bug 82366 has been marked as a duplicate of this bug. ***
The actual explanation fail to state what are the requirements to make the two commands possible (dev-db/mysql-5.0.26-r1). I don't understand how my machine could be misconfigured because the same sort of command work when done from mysql (and not mysqladmin) barton ~ # hostname barton barton ~ # hostname -f barton.maison barton ~ # rm -rf /var/lib/mysql/* barton ~ # /usr/bin/mysql_install_db Installing all prepared tables Fill help tables To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h barton password 'new-password' See the manual for more instructions. You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe & You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory: cd sql-bench ; perl run-all-tests Please report any problems with the /usr/bin/mysqlbug script! The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com barton ~ # /etc/init.d/mysql start * Starting mysql ... * Starting mysql (/etc/mysql/my.cnf) [ ok ] barton ~ # /usr/bin/mysqladmin -u root password 'new-password' barton ~ # /usr/bin/mysqladmin -u root -h barton password 'new-password' /usr/bin/mysqladmin: connect to server at 'barton' failed error: 'Lost connection to MySQL server during query' barton ~ # /etc/init.d/mysql stop * Stopping mysql ... * Stopping mysqld (0) [ ok ] barton ~ # rm -rf /var/lib/mysql/* barton ~ # /usr/bin/mysql_install_db ... barton ~ # /etc/init.d/mysql start * Starting mysql ... * Starting mysql (/etc/mysql/my.cnf) [ ok ] barton ~ # /usr/bin/mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 5.0.26-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('nouveau_pass'); Query OK, 0 rows affected (0.00 sec) mysql> SET PASSWORD FOR 'root'@'barton' = PASSWORD('nouveau_pass_2'); Query OK, 0 rows affected (0.00 sec) So what the requirements to make work mysqladmin -u root -h $hostname password 'new-password' Is-it really what should be done?