GRANT SELECT ON *.* TO 'fc'@'192.168.189.133'> 通过隧道在本地连接MySQL服务器
[root@localhost ~]# mysql -ufc -P 3388 -h 127.0.0.1 -p111111
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection> Server version: 5.1.48-log Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
4 rows in set (0.00 sec)
测试成功
由于服务器重启隧道会失效
这项开通本地隧道需要加入/etc/rc.d/rc.local中
ssh -NCPf root@192.168.189.139 -L 3388:192.168.189.139:3306
二、windows平台的客户端连接linux上的Mysql服务器
具体设置参考http://holy2010.blog.51cto.com/1086044/518431
用navicat for myql 连接Linux上的mysql
方法很简单只要在这个软件设置ssh这个功能就可以
general选项中填写本地数据库的信息
SSH选项中Use ssh Tunnel 填写远程Linux的账户和密码就可以,ssh的端口 22
Test connection