[MDEV-8498] mysql_secure_installation can't find "mysql" in basedir Created: 2015-07-17  Updated: 2015-10-26  Resolved: 2015-10-26

Status: Closed
Project: MariaDB Server
Component/s: Scripts & Clients
Affects Version/s: 10.0.20, 10.1.5
Fix Version/s: 10.0.22, 10.1.9

Type: Bug Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: Sergey Vojtovich
Resolution: Fixed Votes: 0
Labels: None

Sprint: 10.0.22

 Description   

If the "mysql" client is not found in $PATH, then mysql_secure_installation won't find it from in basedir:

[gmontee@localhost mariadb-10.1.5-linux-x86_64]$ ./bin/mysql_secure_installation -u root --basedir=/tmp/mariadb-10.1.5-linux-x86_64/
print: /tmp/mariadb-10.1.5-linux-x86_64//bin/my_print_defaults
 
FATAL ERROR: Could not find mysql
 
The following directories were searched:
 
/tmp/mariadb-10.1.5-linux-x86_64//bin
 
If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.
 
If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.

But it will find it if added to $PATH:

[gmontee@localhost mariadb-10.1.5-linux-x86_64]$ export PATH=$PATH:/tmp/mariadb-10.1.5-linux-x86_64/bin
[gmontee@localhost mariadb-10.1.5-linux-x86_64]$ ./bin/mysql_secure_installation -u root --basedir=/tmp/mariadb-10.1.5-linux-x86_64/
print: /tmp/mariadb-10.1.5-linux-x86_64//bin/my_print_defaults
 
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
 
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, 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):

I think the bug happens because bindir is set to use basedir here: https://github.com/MariaDB/server/blob/d258f5ff0435cbd8b000226dc7dc3ec4e9b79cbc/scripts/mysql_secure_installation.sh#L176

But then find_in_basedir is called here: https://github.com/MariaDB/server/blob/d258f5ff0435cbd8b000226dc7dc3ec4e9b79cbc/scripts/mysql_secure_installation.sh#L184

Which adds basedir to the path again here: https://github.com/MariaDB/server/blob/d258f5ff0435cbd8b000226dc7dc3ec4e9b79cbc/scripts/mysql_secure_installation.sh#L83

So if basedir is /usr/local/mysql, it will search for /usr/local/mysql/usr/local/mysql/bin/mysql.



 Comments   
Comment by Sergey Vojtovich [ 2015-10-23 ]

serg, please review fix for this bug.

Comment by Sergei Golubchik [ 2015-10-23 ]

ok to push

Generated at Thu Feb 08 07:27:36 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.