LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-19-2007, 04:18 AM   #1
crimson.dynamo
LQ Newbie
 
Registered: Jun 2007
Posts: 6

Rep: Reputation: 0
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.

Thanks

Last edited by crimson.dynamo; 06-19-2007 at 04:20 AM.
 
Old 06-20-2007, 08:14 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
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
 
Old 06-20-2007, 08:36 AM   #3
crimson.dynamo
LQ Newbie
 
Registered: Jun 2007
Posts: 6

Original Poster
Rep: Reputation: 0
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.
 
Old 06-20-2007, 08:58 AM   #4
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,263

Rep: Reputation: 297Reputation: 297Reputation: 297
Hi

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
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games

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"
 
Old 06-20-2007, 09:08 AM   #5
crimson.dynamo
LQ Newbie
 
Registered: Jun 2007
Posts: 6

Original Poster
Rep: Reputation: 0
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".
 
Old 06-20-2007, 09:33 AM   #6
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,263

Rep: Reputation: 297Reputation: 297Reputation: 297
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.
 
Old 06-20-2007, 10:19 AM   #7
crimson.dynamo
LQ Newbie
 
Registered: Jun 2007
Posts: 6

Original Poster
Rep: Reputation: 0
My current PATH is:
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin

I have mySql installed in
/usr/local/mysql/bin

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=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}

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

pathmunge /usr/X11R6/bin after

unset pathmunge

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

USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"

HOSTNAME=`/bin/hostname`
HISTSIZE=1000

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

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

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

unset i


Do I just add the export command to the bottom of this file?
 
Old 06-20-2007, 10:24 AM   #8
crimson.dynamo
LQ Newbie
 
Registered: Jun 2007
Posts: 6

Original Poster
Rep: Reputation: 0
obviously my /etc/profile isn't actually that cheerful and those smilies should be colon-brackets. ;-)
 
Old 06-20-2007, 10:25 AM   #9
crimson.dynamo
LQ Newbie
 
Registered: Jun 2007
Posts: 6

Original Poster
Rep: Reputation: 0
I can't even add a smiley when I try!!!
 
Old 06-20-2007, 10:36 AM   #10
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,263

Rep: Reputation: 297Reputation: 297Reputation: 297
Hi

Just add
Quote:
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. suziecorbett Linux - Software 8 10-09-2008 02:52 AM
installed mysql 5.0 and mysql command not available mariogarcia Debian 2 05-24-2006 06:57 PM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 09:44 AM
MySQL setup stops at command "./configure --prefix=/usr/local/mysql" k41184 Linux - Software 1 05-20-2004 03:44 PM
MySQL command prompt (/usr/local/mysql missing) sankar555 Linux - Software 3 03-22-2003 01:48 PM


All times are GMT -5. The time now is 04:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration