-   Linux - Newbie (
-   -   can't make mysql command run the right mysql version (

crimson.dynamo 06-19-2007 03:18 AM

can't make mysql command run the right mysql version
Hi all

I have recently installed new versions of apache, php, mysql and perl on a Red Hat Linux 9 machine. They are all working well, but I did not uninstall the old versions. This is causing problems as I cannot just start one of these applications with a one word command - ie. typing mysql will start the old version of mysql not the new one.

I can get around this by supplying the full path to the programs, but it still causes lots of problems when I am using prewritten scripts. Obviously there is some setting somewhere that says that the mysql command calls a particular version of mysql. Where is it? How do I change it to point to my new version?

It's bound to be something simple that I just haven't figured. I'd be gratefull for any help you can give.


chrism01 06-20-2007 07:14 AM

Just FYI, RH9 is waaay old and unsupported eg security updates etc.
That distro line has been superceded by RH Fedora Core series, now at v7 (!)
Incidentally, that'll have the new versions already to go :)

crimson.dynamo 06-20-2007 07:36 AM

Unfortunately I am not in a position to upgrade the OS running on the machine. I'm just in charge of getting a few things working again on it.

I use Ubuntu 7.04 on my own machine.

Anyone have any ideas on how to sort this problem? Anyone have any ideas on how to phrase my problem better so as to get more responses? - it's a tricky one.

I think the problem is fairly fundamental.

Guttorm 06-20-2007 07:58 AM


When you run a command like "mysql", the shell looks at the PATH variable. It contains a lot of directories separated with a colon. Starting from the left, it looks in every directory for a file called "mysql" with execute permissions. Once it finds one, it runs that file.

Here is mine:
echo PATH

Since /usr/local/bin is before /usr/bin, a self-compiled mysql in /usr/local/bin will be used instead of the package management system's in /usr/bin.

So, if you installed mysql with --prefix=/usr/local
export PATH="/usr/local/bin:$PATH"

crimson.dynamo 06-20-2007 08:08 AM

How do I change my PATH so as it will find my new applications first?

How do I find out what my current PATH is? I typed "echo PATH", but all it returned was "PATH".

Guttorm 06-20-2007 08:33 AM

Oops, its "echo $PATH"

export PATH="/usr/local/bin:$PATH"
will add to it.

But it won't be saved after you log out. I really don't know RedHat 9 - but most systems have a file called "/etc/profile". Putting the export command at the end of that file will change it for all users, that file is run when any user logs in.

crimson.dynamo 06-20-2007 09:19 AM

My current PATH is:

I have mySql installed in

Should I use the export command for this directory? And also add the directories for the other applications that are giving me trouble?

Using the export command with the above directory worked for my current session.

I do have /etc/profile, it currently looks like this:
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

pathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then

# Path manipulation
if [ `id -u` = 0 ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin

pathmunge /usr/X11R6/bin after

unset pathmunge

# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

USER="`id -un`"


if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then


for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i

unset i

Do I just add the export command to the bottom of this file?

crimson.dynamo 06-20-2007 09:24 AM

obviously my /etc/profile isn't actually that cheerful and those smilies should be colon-brackets. ;-)

crimson.dynamo 06-20-2007 09:25 AM

I can't even add a smiley when I try!!! ;)

Guttorm 06-20-2007 09:36 AM


Just add

export PATH="/usr/local/mysql/bin:$PATH"
at the end of the script.

Click "Go Advanced" to be able to disable smilies and other formatting options.

All times are GMT -5. The time now is 07:42 PM.