开始我理解是,删除软链,也许要重新退出session才能生效,但事实上是环境变量的问题。由于之前已经有5.5.39版本,bin路径是 /usr/local/mysql/bin/mysql ,后来安装了 5.0.96,bin路径指向 /usr/bin/mysql,虽然之前把 /usr/local/mysql 软链去掉了,环境变量认为mysql还是要读取 /usr/local/mysql/bin/mysql,而不会去读取最新的 /usr/bin/mysql,所以报路径错误,退出session以后,等于是对环境变量的路径做了一次更新,去读取/usr/bin/mysql
那么假设我现在又想用5.5.39客户端程序去连5.0.96服务器呢?是不是简单地加上软链,然后退出session就可以了呢?我们来看一下
mysql> exit
Bye
[root@bak ~]# cd /usr/local
[root@bak local]# ln -s /opt/mysql/mysql-5.5.39-linux2.6-i686/ mysql
[root@bak local]# ll
total 72
drwxr-xr-x 2 mysql 502 4096 Aug 25 11:39 bin
drwxr-xr-x 2 mysql 502 4096 Aug 8 2008 etc
drwxr-xr-x 2 mysql 502 4096 Aug 8 2008 games
drwxr-xr-x 2 mysql 502 4096 Aug 8 2008 include
drwxr-xr-x 2 mysql 502 4096 Aug 8 2008 lib
drwxr-xr-x 2 mysql 502 4096 Aug 8 2008 libexec
lrwxrwxrwx 1 root root 38 Oct 17 16:14 mysql -> /opt/mysql/mysql-5.5.39-linux2.6-i686/
drwxr-xr-x 2 mysql 502 4096 Aug 8 2008 sbin
drwxr-xr-x 5 mysql 502 4096 Aug 25 11:39 share
drwxr-xr-x 2 mysql 502 4096 Sep 23 20:34 src
[root@bak local]# exit
断开session……
Last login: Fri Oct 17 16:07:04 2014 from 192.168.1.100 --重新连上服务器
[root@bak ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.96-community-log MySQL Community Edition (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> \s
--------------
mysql Ver 14.12 Distrib 5.0.96, for pc-linux-gnu (i686) using readline 5.1
Connection id: 3
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.0.96-community-log MySQL Community Edition (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /var/lib/mysql/mysql.sock
Uptime: 9 min 17 sec
Threads: 1 Questions: 12 Slow queries: 0 Opens: 12 Flush tables: 1 Open tables: 6 Queries per second avg: 0.022
--------------
mysql>
是不是觉得很奇怪?这次重新添加了软链指向了5.5.39的bin路径,也退出了sesssion更新环境变量,怎么mysql还是去连了5.0.96的bin路径里的mysql客户端呢?再来看一下PATH环境变量的设置
mysql> exit
Bye
[root@bak ~]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/mysql/bin:/root/bin
[root@bak ~]#