无法连接到任何指定的 MySQL 主机。尝试连接 mysql 时

无法连接到任何指定的 MySQL 主机。尝试连接 mysql 时

我使用 go daddy vps,安装了 mysql,配置了 /etc/my.cnf 如下所示:

[mysqld]
user=mysql
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
port=3306
# bind-address=1xx.1xx.1xx.148
bind-address=1xx.1xx.1xx.148
skip-networking

# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

然后当我在 /var/log/mysql.log 中看到时,我看到 mysql 已正确启动:

120113 03:58:59  mysqld started
120113  3:58:59 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
120113  3:58:59 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
120113  3:58:59  InnoDB: Started; log sequence number 0 43665
120113  3:58:59 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.0.77'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution

但当我这样做时:

/usr/sbin/lsof -i:3306

我什么也没看到。当我看到时:

 netstat -a |grep LISTEN

tcp        0      0 localhost.localdomain:smtp  *:*                         LISTEN
tcp        0      0 *:http                      *:*                         LISTEN
tcp        0      0 *:ssh                       *:*                         LISTEN
tcp        0      0 *:https                     *:*                         LISTEN
unix  2      [ ACC ]     STREAM     LISTENING     244331015 /var/run/saslauthd/mux
unix  2      [ ACC ]     STREAM     LISTENING     247310795 /var/lib/mysql/mysql.sock

所以我看到某种 mysql socked 监听...但是当我尝试从我的 Toad 连接到远程服务器时我得到了:
无法连接到任何指定的 MySQL 主机。

我正在连接到 mysql 根用户。连接到端口 3306 上的应用程序数据库。我还发现网络上有很多帖子说要删除 skip-networking。但是当我这样做时。当我尝试启动数据库时出现此错误:

120113 14:46:36  mysqld started
120113 14:46:36 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
120113 14:46:36 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
120113 14:46:36  InnoDB: Started; log sequence number 0 43665
120113 14:46:36 [ERROR] Can't start server: Bind on TCP/IP port: Cannot assign requested address
120113 14:46:36 [ERROR] Do you already have another mysqld server running on port: 3306 ?
120113 14:46:36 [ERROR] Aborting

120113 14:46:36  InnoDB: Starting shutdown...
120113 14:46:37  InnoDB: Shutdown completed; log sequence number 0 43665
120113 14:46:37 [Note] /usr/libexec/mysqld: Shutdown complete

120113 14:46:37  mysqld ended

并且我在这个端口上没有运行任何 mysql,或者根本没有运行任何 mysql...
这里有什么问题?

答案1

您认为这是什么skip-networking意思?删除此语句,它应该可以正常工作。请参阅这里以获得解释。

答案2

  1. C:\Program Files (x86)\MySQL\MySQL 服务器 5.0\bin
  2. 点击 MySQLInstanceConfig.exe
  3. 重新配置你的 mysql

注意:此过程不会影响您的数据库。

相关内容