mysql_connect problem
am 25.07.2006 11:38:33 von greasydan
Hi All,
I've got MySQL 5.0.21 running on Windows Server 2003, and php running
on Apache on a Linux box (Fedora Core 4).
Previously when the pages were running on an IIS server the connection
was succesful, now I get:
Can't connect to MySQL server on 'SERVER' (13)
I'm connecting using:
$db = mysql_connect("SERVER", "USER", "PASSWORD")
or die("Could not connect to database:
".mysql_error());
mysql_select_db("DATABASE", $db)
or die("Could not select database: ".mysql_error());
However from the linux box I can connect no problems using:
mysql --host=SERVER -u USER -p
My phpinfo() relating to MySQL is as follows:
>From phpinfo():
Active Persistent Links 0
Active Links 0
Client API version 4.1.11
MYSQL_MODULE_TYPE external
MYSQL_SOCKET /var/lib/mysql/mysql.sock
MYSQL_INCLUDE -I/usr/include/mysql
MYSQL_LIBS -L/usr/lib/mysql -lmysqlclient
Can anyone help point me in the right direction to solve this one?
Cheers
Dan
Re: mysql_connect problem
am 25.07.2006 13:27:46 von Richard Hulbert
On 2006-07-25 10:38:33 +0100, greasydan@gmail.com said:
> Hi All,
>
> I've got MySQL 5.0.21 running on Windows Server 2003, and php running
> on Apache on a Linux box (Fedora Core 4).
>
> Previously when the pages were running on an IIS server the connection
> was succesful, now I get:
>
> Can't connect to MySQL server on 'SERVER' (13)
>
> I'm connecting using:
>
> $db = mysql_connect("SERVER", "USER", "PASSWORD")
> or die("Could not connect to database:
> ".mysql_error());
> mysql_select_db("DATABASE", $db)
> or die("Could not select database: ".mysql_error());
>
> However from the linux box I can connect no problems using:
> mysql --host=SERVER -u USER -p
>
> My phpinfo() relating to MySQL is as follows:
>> From phpinfo():
>
> Active Persistent Links 0
> Active Links 0
> Client API version 4.1.11
> MYSQL_MODULE_TYPE external
> MYSQL_SOCKET /var/lib/mysql/mysql.sock
> MYSQL_INCLUDE -I/usr/include/mysql
> MYSQL_LIBS -L/usr/lib/mysql -lmysqlclient
>
> Can anyone help point me in the right direction to solve this one?
> Cheers
> Dan
Have you ever connected to this DB? When you connect to mySQL it checks
to see where the request is comming from. lets say that your mySQL
server is on the same machine as your php pages that are trying to
connect to it. SERVER = localhost or 127.0.0.1 if your connection has
those privelliges then all well and good you can connect however if you
try to connect to the same server from another machine the you will get
rejected. you can make as many connections as you like so you could
make another connection for that machine that specifies that it is
comming form another machine.
Richard
Re: mysql_connect problem
am 25.07.2006 13:41:21 von greasydan
Richard Hulbert wrote:
> Have you ever connected to this DB? When you connect to mySQL it checks
> to see where the request is comming from. lets say that your mySQL
> server is on the same machine as your php pages that are trying to
> connect to it. SERVER = localhost or 127.0.0.1 if your connection has
> those privelliges then all well and good you can connect however if you
> try to connect to the same server from another machine the you will get
> rejected. you can make as many connections as you like so you could
> make another connection for that machine that specifies that it is
> comming form another machine.
>
> Richard
Hi Richard,
I am able to connect from the command line to the db on the windows
box, just not via mysql_connect() on the php pages.
eg:
mysql --host=SERVER -u USER -p
works like a dream
BUT
$db = mysql_connect("SERVER", "USER", "PASSWORD")
or die("Could not connect to database:
".mysql_error());
gives me:
Could not connect to database: Can't connect to MySQL server on
'SERVER' (13)
Cheers
Dan