我有一个用putty访问的linux服务器。
我使用程序SQuirrel SQL客户端访问该服务器的mysql数据库。
一切正常。现在我买了一台新的Windows电脑,我想安装所有相同的应用程序来访问我的linux服务器。
我可以很好地使用putty访问我的服务器。
我安装了SQuirrel并使用相同的驱动程序,属性来访问数据库,但我不能正常工作。
我收到以下错误:
MESSAGE: Connection refused: connect
STACKTRACE:
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:69)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at java.net.Socket.<init>(Socket.java:425)
at java.net.Socket.<init>(Socket.java:208)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:121)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:220)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1768)
at com.mysql.jdbc.Connection.<init>(Connection.java:440)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:400)
at net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager.getConnection(SQLDriverManager.java:133)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.executeConnect(OpenConnectionCommand.java:167)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.access$000(OpenConnectionCommand.java:45)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand$1.run(OpenConnectionCommand.java:104)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
** END NESTED EXCEPTION **
我该如何解决这个问题?
答案 0 :(得分:0)
修改/etc/my.cnf
运行:vi /etc/my.cnf
寻找bind-address=YOUR-SERVER-IP
并将其评论出来。
如果要为用户栏和远程IP 202.54.10.20添加名为foo的新数据库 然后你需要在
输入以下命令mysql> prompt:
mysql> CREATE DATABASE foo;
mysql> GRANT ALL ON foo.* TO bar@'202.54.10.20' IDENTIFIED BY 'PASSWORD';
让我们假设您始终从名为202.54.10.20的远程IP连接到用户webadmin的名为webdb的数据库,要授予对此IP地址的访问权限,请键入以下命令
mysql> prompt for existing database, enter:
mysql> update db set Host='202.54.10.20' where Db='webdb';
mysql> update user set Host='202.54.10.20' where user='webadmin';
退出mysql,
您现在必须重新启动您的mysql服务器实例 这应该允许你远程连接。