分类: Mysql/postgreSQL
2008-02-15 15:28:48
进入客户端后切换服务器连接的做法。
只能是切换到和另外一个SERVER端口,用户名,密码都是一样的。
原来SERVER:A。
切换的SERVER:B。
B上的操作:
mysql> grant usage,select on *.* to root@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> status
--------------
/usr/local/mysql/bin/mysql Ver 14.12 Distrib 5.0.45, for pc-linux-gnu (i686) using readline 5.0
Connection id: 9
Current database: mysql
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.0.45-log MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /tmp/mysql.sock
Uptime: 3 days 6 hours 30 min 0 sec
Threads: 1 Questions: 59 Slow queries: 0 Opens: 12 Flush tables: 1 Open tables: 6 Queries per second avg: 0.000
--------------
mysql> show processlist;
+----+-------------+-----------+------+---------+--------+-----------------------------------------------------------------------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-------------+-----------+------+---------+--------+-----------------------------------------------------------------------+------------------+
| 2 | system user | | NULL | Connect | 282919 | Has read all relay log; waiting for the slave I/O thread to update it | NULL |
| 9 | root | localhost | test | Query | 0 | NULL | show processlist |
+----+-------------+-----------+------+---------+--------+-----------------------------------------------------------------------+------------------+
2 rows in set (0.00 sec)
A上的操作:
mysql> \r test 192.168.0.232
Connection id: 23
Current database: test
mysql> status
--------------
mysql Ver 14.14 Distrib 5.1.22-rc, for redhat-linux-gnu (i686) using readline 5.0
Connection id: 23
Current database: test
Current user: root@192.168.0.231
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.1.22-rc-log MySQL Community Server (GPL)
Protocol version: 10
Connection: 192.168.0.232 via TCP/IP
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
TCP port: 3306
Uptime: 3 days 6 hours 33 min 10 sec
Threads: 2 Questions: 77 Slow queries: 1 Opens: 12 Flush tables: 1 Open tables: 9000 Queries per second avg: 0.000
--------------
mysql> show processlist;
+----+------+---------------------+------+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+---------------------+------+---------+------+-------+------------------+
| 9 | root | localhost | test | Sleep | 25 | | NULL |
| 23 | root | 192.168.0.231:34173 | test | Query | 0 | NULL | show processlist |
+----+------+---------------------+------+---------+------+-------+------------------+
2 rows in set (0.00 sec)
mysql>
连接后B上的操作:
mysql> show processlist;
+----+-------------+---------------------+------+---------+--------+-----------------------------------------------------------------------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-------------+---------------------+------+---------+--------+-----------------------------------------------------------------------+------------------+
| 2 | system user | | NULL | Connect | 282869 | Has read all relay log; waiting for the slave I/O thread to update it | NULL |
| 9 | root | localhost | test | Query | 0 | NULL | show processlist |
| 23 | root | 192.168.0.231:34173 | test | Sleep | 69 | | NULL |
+----+-------------+---------------------+------+---------+--------+-----------------------------------------------------------------------+------------------+
3 rows in set (0.00 sec)
现在已经连接上了。