MySQL Forums
Forum List  »  Newbie

Need some clarifications about mysqld_safe
Posted by: Anthony Shi
Date: May 10, 2023 03:42AM

I was going through the mysqld_safe script that is shipped with MySQL Version 8.0.33-linux-glibc2.28-x86_64 and came across something quite puzzling. On line 421 of the script, we have:

find_basedir_from_cmdline "$@"

Here, the find_basedir_from_cmdline() function was called on the command line arguments. If --basedir was present among the command line arguments, then both MY_BASEDIR_VERSION and 'ledir' will be set accordingly if the base directory is valid.

But what if the user specifies 'basedir' inside an option file but didn't provide 'ledir'? If I were to run ./bin/mysqld_safe --defaults-file=file.cnf, wouldn't the 'basedir' option be ignored? Even if I have a 'basedir' option inside file.cnf, the conditional on line 424 will fail as long as I didn't specify --basedir=file.cnf on the command line. As a result 'ledir' will either be set to '$MY_PWD/$dir' or '/usr/local/mysql/bin'

It's true that parse_arguments() will be called on lines 500 to 507. This will update MY_BASEDIR_VERSION to the one specified in file.cnf, but NOT 'ledir', which was already set on line 449. So when mysqld_safe is looking for the server daemon (line 867), it uses the 'ledir' set on line 449 instead of the 'ledir' inside the basedir specified in file.cnf

It seems like we must provide a 'ledir' option inside the option file as well, which seems a bit redundant.

Am I missing something here?

Options: ReplyQuote

Written By
Need some clarifications about mysqld_safe
May 10, 2023 03:42AM

Sorry, you can't reply to this topic. It has been closed.

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.