Bug #82496 mysqld --initialize does not properly create root accounts
| Submitted: | 8 Aug 2016 20:26 | Modified: | 26 Jun 2018 2:57 |
|---|---|---|---|
| Reporter: | Davi Arnaut (OCA) | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Documentation | Severity: | S3 (Non-critical) |
| Version: | 5.7.14 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | initialize, initialize-insecure, regression, root@127.0.0.1 | ||
[8 Aug 2016 20:26]
Davi Arnaut
[8 Aug 2016 20:29]
Davi Arnaut
Updated synopsis and tags.
[8 Aug 2016 21:28]
MySQL Verification Team
Thank you for the bug report. C:\dbs>c:\dbs\5.6\bin\mysql -uroot --port=3560 -p --prompt="mysql 5.6 > " Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.33 Source distribution 2016-JUL-09 Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql 5.6 > select host from mysql.user where user='root'; +-----------+ | host | +-----------+ | 127.0.0.1 | | ::1 | | localhost | +-----------+ 3 rows in set (0.00 sec) mysql 5.6 > exit Bye C:\dbs>57 C:\dbs>c:\dbs\5.7\bin\mysql -uroot -p --port=3570 --prompt="mysql 5.7 > " Enter password: ****** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.15 Source distribution 2016-JUL-09 Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql 5.7 > select host from mysql.user where user='root'; +-----------+ | host | +-----------+ | localhost | +-----------+ 1 row in set (0.05 sec)
[10 Aug 2016 9:23]
Georgi Kodinov
Davi, This is actually an intentional change. See http://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-6.html (and more specifically the section on initialize) and http://dev.mysql.com/doc/refman/5.7/en/server-options.html#option_mysqld_skip-name-resolve where it says that you need to add the accounts if you're to use the option. mysql_install_db is deprecated in 5.7 (in favor of the --initialize option) and the server initializes by default as if mysql_secure_installation is run. We don't support --skip-name-resolve out of the box as it is a popular gotcha wrt password updates and privilege assignments. Note that --initialize works with --init-file (http://dev.mysql.com/doc/refman/5.7/en/server-options.html#option_mysqld_init-file) so you can automate creating these accounts if you must. If you feel the lack of the "other" root accounts is not clear enough please re-open the bug as a documentation one.
[10 Aug 2016 9:36]
Davi Arnaut
Georgi, Could you quote exactly where it says that the accounts are intentionally not created? The remark about in skip-name-resolve about creating accounts is also in the 5.6 manual, yet the accounts are created. Also, none of this is listed in the incompatible changes section of the manual. I'm not sure also why you are telling me that mysql_install_db is deprecated, I don't care about that. > We don't support --skip-name-resolve out of the box as it is a popular gotcha wrt password updates and privilege assignments. What? so --skip-name-resolve is no longer supported? But again, that's beside the point, the accounts are no longer there. That's orthogonal to whether --skip-name-resolve is supported or not. --init-file is not an accepted work around.
[10 Aug 2016 9:47]
Davi Arnaut
Might be worth reminding that before 5.7 the only supported way to initialize the data directory was mysql_install_db. Whatever it did got established as the default contents of the users tables and etc. Whether it got deprecated or not doesn't matter with respect to expectations of what should be the content of the data directory after initialization. I would also like to see where it says that skip-name-resolve is not supported. That's an option used in several MySQL installations to avoid dealing with DNS issues. Would also love to hear an explanation why the other accounts cannot be created. This sort of change creates upgrades pains and it's not clear why.
[10 Aug 2016 10:01]
Davi Arnaut
To expand why --init-file does't work: installation is automated using a deployment management system that installs MySQL packages (e.g. rpm, deb). When the package is installed, the data directory is initialized though whatever the package specification does. In any case, the deployment management system is not able to connect to the service.
[11 Aug 2016 8:56]
Georgi Kodinov
Davi, On where it's specified, http://dev.mysql.com/doc/refman/5.7/en/mysql-install-db.html says: Current versions of mysql_install_db produce a MySQL deployment that is secure by default. It is recommended that you use mysql_install_db from MySQL 5.7.5 or up for best security, but version-dependent information about security characteristics is included here for completeness (secure-by-default deployment was introduced in stages in MySQL 5.7). MySQL 5.7.5 and up is secure by default, with these characteristics: A single administrative account named 'root'@'localhost' is created with a randomly generated password, which is marked expired. No anonymous-user accounts are created. .... As for the incompatible changes section you're correct that it's not there. But I'm guessing it wasn't added due to the fact that it applies to new installations only. As I've suggested feel free to open a documentation bug if you feel the text should be more explicit. As to the deprecation warning I believe these are important since we will eventually remove the deprecated bits in a future version. I know mysql_install_db was the preferred way to initialize a database but it has a number of flaws that we addressed by adding the --initialize mysqld option, e.g. it was a shell script that didn't run on some platforms, it depended on external files that may or may not be the correct ones etc. --skip-name-resolve is of course a supported option. However, since it is an "expert" option that is not on by default IMHO it's not unfair to expect that one would need to do some extra steps to make it work on a default database installation. I also believe that if you start the server with no suitable accounts that can be used in the mode it's in you will receive a warning in the server's log. Can the server do better than that ? Probably it could temporarily add a superuser account with the same authentication as the existing super user account. The problem is that if there're multiple superuser accounts it'd still need guidance. I will of course be happy to discuss any enhancement ideas in that direction. The logic behind having to do the extra steps is that we wanted to make mysql 5.7 secure by default for the novice user. So we decided to make the default installation such that there would be no need to run mysql_secure_installation on it. Specifically for the root@127.0.0.1 account: novice users typically struggle with the idea that there are multiple super user accounts each having their own separate password. So very frequently they just forget to set a strong password for these extra accounts. Or manipulate the unique set of privileges assigned to these. I understand what you are saying wrt why --init-file is not a good workaround. I am sure the packaging systems used allow running commands at install time. So one could conceivably have an add-on "package" that: - depends on the mysql packages - makes sure the mysqld service is started - executes a script against it altering the default installation in the desired way Even I, with my limited rpm spec knowledge, can probably create one such RPM.
[11 Aug 2016 15:11]
MySQL Verification Team
Yes, this does look like a simple documentation bug. One sentences would resolve the entire issue.
[11 Aug 2016 22:11]
Davi Arnaut
> Even I, with my limited rpm spec knowledge, can probably create one such RPM. Good for you, but there is no need for any of that. At this point the workaround is to connect over unix domain socket using the mysql client. Even though it would be easy and secure to connect over localhost using TCP/IP. Just goes to show how that not having the account doesn't really improve security at all and creates unnecessary inconvenience for users that already have to deal with a lot of other problems. This doesn't make things easier for anyone.
[11 Aug 2016 22:17]
Davi Arnaut
> Specifically for the root@127.0.0.1 account: novice users typically struggle with the idea that there are multiple super user accounts each having their own separate password. So very frequently they just forget to set a strong password for these extra accounts. Or manipulate the unique set of privileges assigned to these. But there is nothing that prevents you from setting the same strong password for the other accounts, or, addressing the issue of forgetting to change the passwords. This went to the easy route for developers, which was to get rid of the accounts, in detriment to and pushing work towards users that have to change their automation tools to handle this.
[12 Aug 2016 13:42]
MySQL Verification Team
Davi, This is just a documentation bug .... as explained above.
[26 Jun 2018 2:57]
Paul DuBois
Posted by developer: Updated these sections to mention the need to create the extra accounts after initialization if you plan to run the server with --skip-name-resolve: https://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysqld.html https://dev.mysql.com/doc/refman/5.7/en/upgrading-from-previous-series.html
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.069 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.