Bug #61573 Remove dependency on 'hostname' binary
Submitted: 21 Jun 2011 7:18 Modified: 15 Dec 2016 12:49
Reporter: Andrea Scarpino Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Installing Severity:S4 (Feature request)
Version:5.5.13 OS:Linux
Assigned to: CPU Architecture:Any
Tags: Contribution

[21 Jun 2011 7:18] Andrea Scarpino
Description:
On Linux, the hostname can be set via this file if available, precluding
the need for a `hostname` binary.

How to repeat:
remove hostname and try to install mysql

Suggested fix:
--- mysql-5.5.13/scripts/mysql_install_db.sh~   2011-06-21 07:12:11.907452275 +0000
+++ mysql-5.5.13/scripts/mysql_install_db.sh    2011-06-21 07:16:26.266518683 +0000
@@ -317,7 +317,11 @@
 fi
 
 # Try to determine the hostname
-hostname=`@HOSTNAME@`
+if [ -f /proc/sys/kernel/hostname ]; then
+  hostname=$(cat /proc/sys/kernel/hostname)
+else
+  hostname=`@HOSTNAME@`
+fi
 
 # Check if hostname is valid
 if test "$cross_bootstrap" -eq 0 -a "$in_rpm" -eq 0 -a "$force" -eq 0
[22 Jun 2011 17:03] Valeriy Kravchuk
Thank you for the feature request and patch contributed.
[11 Oct 2011 8:44] Andrea Scarpino
Status?
[15 Dec 2016 12:49] Erlend Dahl
[14 Dec 2016 13:05] Yngve Svendsen

mysql_install_db is deprecated as of MySQL 5.7.6, and with 5.5 and 5.6 having
come a fair bit along in their lifecycle, we are limiting the amount of
change in these versions. Thus closing this.