mysql - 在 Debian 上启用到 MySQL 数据库的远程连接

标签 mysql phpmyadmin remote-connection

我在 Debian Lenny 5.0 上安装了一个 MySQL 数据库,我正在尝试使用 PHP 远程连接到该数据库。

这是我登录的方式:

$con = mysql_pconnect("MY_IP_ADDRESS","root","MY_PASSWORD");
if (!$con)
die('Could not connect: ' . mysql_error());

这是我得到的错误:

Could not connect: Access denied for user 'root'@'li273-10.members.linode.com'
(using password: YES)

我不确定为什么我的 linode 用户出现在那里。

为了启用远程连接,我使用了本教程:http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html

我注意到的另一件事是,在我的 MySQL 端的 phpmyadmin 中,我有这个:

Server: localhost via TCP/IP
Server version: 5.0.51a-24+lenny5
Protocol version: 10
User: root@mycooldb

我认为 localhost 必须是我服务器的 IP 地址吗?

我做错了什么?

本教程中有几件事情没有奏效:

保存所有规则:service iptables save 不起作用。我收到此错误:

-bash: service: command not found

最后,当我执行 mysql -u webadmin –h MY_IP –p 时,我得到了这个:enter image description here

最佳答案

您还需要为远程用户创建用户/权限。可能 root 用户仅具有定义为 root@localhost 的权限。

您需要定义用户权限,例如:user@% 或 user@li273-10.members.linode.com。

http://dev.mysql.com/doc/refman/5.0/en/create-user.html

您可能不想授予 super 用户帐户(在本例中为 root)远程访问权限。

您的主机名出现在身份验证行中,因为您实际上以 user@hostname 身份连接到数据库。

关于mysql - 在 Debian 上启用到 MySQL 数据库的远程连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9640354/

相关文章:

php - 从数据库表中打印格式化的多维数组

mysql - 需要提取 logID 并将其用作storedProc 中的变量

php - 用户 'root' @localhost mysql 错误 1045 的访问被拒绝

postgresql - 远程连接到谷歌云 VM 实例中的 postgreSQL 服务器

mysql - 如何每小时访问不同机器的mysql表数据?

sql - 什么会导致合法的 MySql INSERT INTO 命令失败?

mysql - IO 操作超时 MySQL vb.NET 2012

sql-server-2012 - 启用 SQL Server Express 2012 的远程连接

mysql - 使用外键删除其他数据

mysql - 添加触发器的正确​​语法