Bug #10986 mysql_config: incorrect locations when it is a symbolic link
Submitted: 31 May 2005 14:55 Modified: 25 Jul 2005 19:33
Reporter: Geert Vanderkelen Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:4.1.12 OS:Linux (Linux)
Assigned to: Jim Winstead CPU Architecture:Any

[31 May 2005 14:55] Geert Vanderkelen

Usually I install mysql in /usr/local/mysql and make symbolic links of mysql, mysqladmin and mysql_config in /usr/local/bin.
Executing `mysql_config --libs` I got wrong results though:

$ /usr/local/mysql/bin/mysql_config --libs
-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm

$ /usr/local/bin/mysql_config --libs
-L/usr/local/lib -lmysqlclient -lz -lcrypt -lnsl -lm



How to repeat:

$ /usr/local/mysql/bin/mysql_config --libs
-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm

$ ln -s /usr/local/mysql/bin/mysql_config /usr/local/bin/mysql_config
$ /usr/local/bin/mysql_config --libs
-L/usr/local/lib -lmysqlclient -lz -lcrypt -lnsl -lm

Suggested fix:
Change get_full_path() in mysql_config to something like this:
Will check if mysql_config is a symbolic link, if so, get the original file so that will be used to get the basedir.

get_full_path ()
  if [ -h $1 ];
     echo `ls -l $1 | awk '{ print $NF }'`
    case $1 in
     /*)        echo "$1";;
     ./*) tmp=`pwd`/$1; echo $tmp | sed -e 's;/\./;/;' ;;
     *) which $1 ;;

Could use stat instead, but I guess ls and awk are more.. universal
[25 Jun 2005 0:58] 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:

[5 Jul 2005 23:50] Jim Winstead
Fixed in 4.1.13 and 5.0.9.
[25 Jul 2005 19:33] Mike Hillyer
Documented in 4.1.13 and 5.0.9 changelogs:

<listitem><para>The <literal>mysql_config</literal> script did not handle symbolic linking properly. (Bug #10986)</para></listitem>