Bug #48086 mysql_secure_installation does NOT work on Solaris
Submitted: 15 Oct 2009 14:39 Modified: 12 Mar 2010 17:13
Reporter: Valeriy Kravchuk Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.1.39, 5.1.41-bzr OS:Solaris (Solaris 10)
Assigned to: Timothy Smith CPU Architecture:Any
Triage: Triaged: D3 (Medium)

[15 Oct 2009 14:39] Valeriy Kravchuk
Description:
mysql_secure_installation script starts with:

#!/bin/sh

and on Solaris 10, for example, this is a classic shell, not a link to bash. Still, script uses syntax that works correct only on bash, like:

if ! reload_privilege_tables; then
exit 1

How to repeat:
Install recent 5.1.x version on Solaris 10, run mysql_install_db, start server and then run mysql_secure_installation script. Answer Y to the question about setting password, enter some simple password like "root" or "mysql", then answer Y to question about removing anonymous users. Observe a failure.

Suggested fix:
Use some more generic syntax like:

reload_privilege_tables
if [ $? -ne 0 ]; then
exit 1
[15 Oct 2009 14:40] Valeriy Kravchuk
Verified with 5.1.39:

-bash-3.00$ bin/mysql -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.39 MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit
Bye
-bash-3.00$ bin/mysql_secure_installation 

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
bin/mysql_secure_installation: !: not found

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
ERROR 1045: Access denied for user 'root'@'localhost' (using password: YES)
 ... Failed!

Workarounds: use #!/usr/bin/bash if you have it, or modify the script as described earlier.
[19 Oct 2009 21:03] Timothy Smith
Similar to Bug#48031
[30 Oct 2009 22:21] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/88818

2835 Timothy Smith	2009-10-30
      Bug#48086: mysql_secure_installation does NOT work on Solaris
      
      Remove a bash-ism (if ! ...).
[2 Nov 2009 9:29] Bjørn Munch
OK, this one appears pretty obvious
[3 Nov 2009 10:18] Joerg Bruehe
Approved.
[3 Nov 2009 20:32] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/89220

2835 Timothy Smith	2009-11-03
      Bug#48086: mysql_secure_installation does NOT work on Solaris
      
      Remove a bash-ism (if ! ...).
[2 Dec 2009 8:01] Bugs System
Pushed into 5.0.89 (revid:joro@sun.com-20091202075830-mzl79q7mc1v72pf1) (version source revid:timothy.smith@sun.com-20091104210831-snletv3dgukwjq64) (merge vers: 5.0.88) (pib:13)
[2 Dec 2009 8:06] Bugs System
Pushed into 5.1.42 (revid:joro@sun.com-20091202080033-mndu4sxwx19lz2zs) (version source revid:kristofer.pettersson@sun.com-20091109223504-xvwgsdqiyuve6frt) (merge vers: 5.1.41) (pib:13)
[15 Dec 2009 2:22] Paul Dubois
Noted in 5.0.89, 5.1.42 changelogs.

mysql_secure_installation did not work on Solaris. 

Setting report to NDI pending push to 5.5.x+
[16 Dec 2009 8:39] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091216083311-xorsasf5kopjxshf) (version source revid:alik@sun.com-20091214191830-wznm8245ku8xo702) (merge vers: 6.0.14-alpha) (pib:14)
[16 Dec 2009 8:46] Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091216082430-s0gtzibcgkv4pqul) (version source revid:alexey.kopytov@sun.com-20091124081906-6pqi7e7sajimog71) (merge vers: 5.5.0-beta) (pib:14)
[16 Dec 2009 8:53] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20091216083231-rp8ecpnvkkbhtb27) (version source revid:alik@sun.com-20091212203859-fx4rx5uab47wwuzd) (merge vers: 5.6.0-beta) (pib:14)
[18 Dec 2009 1:54] Paul Dubois
Noted in 5.5.1, 6.0.14 changelogs.
[12 Mar 2010 14:14] Bugs System
Pushed into 5.1.44-ndb-7.0.14 (revid:jonas@mysql.com-20100312135944-t0z8s1da2orvl66x) (version source revid:jonas@mysql.com-20100312115609-woou0te4a6s4ae9y) (merge vers: 5.1.44-ndb-7.0.14) (pib:16)
[12 Mar 2010 14:30] Bugs System
Pushed into 5.1.44-ndb-6.2.19 (revid:jonas@mysql.com-20100312134846-tuqhd9w3tv4xgl3d) (version source revid:jonas@mysql.com-20100312060623-mx6407w2vx76h3by) (merge vers: 5.1.44-ndb-6.2.19) (pib:16)
[12 Mar 2010 14:46] Bugs System
Pushed into 5.1.44-ndb-6.3.33 (revid:jonas@mysql.com-20100312135724-xcw8vw2lu3mijrhn) (version source revid:jonas@mysql.com-20100312103652-snkltsd197l7q2yg) (merge vers: 5.1.44-ndb-6.3.33) (pib:16)