php在Linux环境下报了MYSQL错误

来源:百度知道 编辑:UC知道 时间:2024/06/03 14:14:31
在Windows环境下一切正常,上传到Linux服务器上就出问题了,错误如下,琢磨了一天没有个结果........
Warning: mysqli::mysqli() [function.mysqli-mysqli]: (00000/1130): Host 'ksftp.ivo.com.cn' is not allowed to connect to this MySQL server in /usr/local/apache/htdocs/IvoRtt/db_fns.php on line 4

Warning: mysqli::query() [function.mysqli-query]: Couldn't fetch mysqli in /usr/local/apache/htdocs/IvoRtt/user_auth_fns.php on line 42
You could not be logged in. You must be logged in to view this page.

第一个错误在 db_fns.php 页面,代码片段为:
<?php
function db_connect() {
$result = new mysqli('192.168.253.103', 'xxxxx', 'xxxxxx', 'ivortt');
if (!$result) {
throw new Exception('Could not connect to database server');
}else{
return $result;
}
}
?>
做数据单笔连接数据库测试可以读写到。
第二个错误在 user_auth_fns.php

function login($username, $password){
// check username and password with db
// if y

Host 'ksftp.ivo.com.cn' is not allowed to connect to this MySQL server

192.168.253.103是你的数据库服务器吧.
在mysql中,用户的标识都是 "username"@"host"
而在你'192.168.253.103'这台mysql服务器中 没有一个用户的 “host”项满足 ksftp.ivo.com.cn这个主机,所以mysq连接失败。

建议你在'192.168.253.103'mysql服务器里面添加一个用户 username@% 然后把你的数据库权限赋给改用户, 你php程序就可以用username这个用户名去连接mysql服务器了

下面说的有道理,O(∩_∩)O~

11111111

服务器没连接上,,,,换到本地用localhost试一下,,