473,394 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

mysql_connect error Apache Web server to Windows hosted database

GD
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

Can anyone help point me in the right direction to solve this one?
Cheers
Dan

Jul 24 '06 #1
6 3345
GD wrote:
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

Can anyone help point me in the right direction to solve this one?
Cheers
Dan
Which version of the MySQL client libraries are being used by
Apache/PHP? If it's pre-MySQL 4.1, it will use a different password
hashing algorithm.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 24 '06 #2
GD

Jerry Stuckle wrote:
>
Which version of the MySQL client libraries are being used by
Apache/PHP? If it's pre-MySQL 4.1, it will use a different password
hashing algorithm.
>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

So this is post-MySQL 4.1?

Thanks
Dan

Jul 24 '06 #3
GD wrote:
Jerry Stuckle wrote:

>>Which version of the MySQL client libraries are being used by
Apache/PHP? If it's pre-MySQL 4.1, it will use a different password
hashing algorithm.

>>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

So this is post-MySQL 4.1?

Thanks
Dan
Yes, that's post 4.1. In that case I would check your server, userid
and password in the mysql_connect() statement very closely.

The fact you can connect from the linux box to the Windows box with
mysql command line utility indicates MySQL on the Windows box is set up
for networking OK, no firewalls in place, etc. The mysql_connect()
statement on the Linux box should use the same type of call.

The only other possibility I can think of is your command line MySQL on
the Linux box might be an older version and you're using pre-4.1
passwords on the Windows MySQL box. "mysql -V" would tell you the
version you're running on the Linux command line.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 24 '06 #4
GD
Jerry Stuckle wrote:
GD wrote:
Jerry Stuckle wrote:
The only other possibility I can think of is your command line MySQL on
the Linux box might be an older version and you're using pre-4.1
passwords on the Windows MySQL box. "mysql -V" would tell you the
version you're running on the Linux command line.
Hi Jerry,

thanks for your suggestions, mysql -V reports that I'm running version:

mysql Ver 14.7 Distrib 4.1.11, for redhat-linux-gnu (i386)

so again it's post-v4.1.
I've looked at the servername, user and password and tried all
permutations, but with no success.
The only other thing I can think of is there's some sort of permissions
problem on the files, rather than the database, but I'm just clutching
at straws now. Any help very gratefully received.

Cheers
Dan

Jul 25 '06 #5
GD wrote:
Jerry Stuckle wrote:
>>GD wrote:
>>>Jerry Stuckle wrote:

>>The only other possibility I can think of is your command line MySQL on
the Linux box might be an older version and you're using pre-4.1
passwords on the Windows MySQL box. "mysql -V" would tell you the
version you're running on the Linux command line.


Hi Jerry,

thanks for your suggestions, mysql -V reports that I'm running version:

mysql Ver 14.7 Distrib 4.1.11, for redhat-linux-gnu (i386)

so again it's post-v4.1.
I've looked at the servername, user and password and tried all
permutations, but with no success.
The only other thing I can think of is there's some sort of permissions
problem on the files, rather than the database, but I'm just clutching
at straws now. Any help very gratefully received.

Cheers
Dan
Dan,

Hmmm, that's possible, I guess. On Linux 13 is "permission denied".
However, I would think you'd have problems even starting Apache if it
couldn't read the mysql libs.

Do you have anything in the [mysql] section of your php.ini?

Also, looking back through your first message - you indicate you get the
message:

Can't connect to MySQL server on 'SERVER' (13)

But your code puts out the messages:

"Could not connect to database: ".mysql_error();
and
"Could not select database: ".mysql_error();

Is this actually the case (your message isn't generated by your code),
or did you just mistype the message? Just want to make sure we're going
down the right path :-).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 25 '06 #6
GD

Jerry Stuckle wrote:
Dan,

Do you have anything in the [mysql] section of your php.ini?

Also, looking back through your first message - you indicate you get the
message:

Can't connect to MySQL server on 'SERVER' (13)

But your code puts out the messages:

"Could not connect to database: ".mysql_error();
and
"Could not select database: ".mysql_error();

Is this actually the case (your message isn't generated by your code),
or did you just mistype the message? Just want to make sure we're going
down the right path :-).
The actual message is:

Could not connect to database: Can't connect to MySQL server on
'SERVER' (13)

MySQL section of php.ini copied below.

[MySQL]
; Allow or prevent persistent links.
mysql.allow_persistent = On

; Maximum number of persistent links. -1 means no limit.
mysql.max_persistent = -1

; Maximum number of links (persistent + non-persistent). -1 means no
limit.
mysql.max_links = -1

; Default port number for mysql_connect(). If unset, mysql_connect()
will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order). Win32 will
only look
; at MYSQL_PORT.
mysql.default_port =

; Default socket name for local MySQL connects. If empty, uses the
built-in
; MySQL defaults.
mysql.default_socket =

; Default host for mysql_connect() (doesn't apply in safe mode).
mysql.default_host =

; Default user for mysql_connect() (doesn't apply in safe mode).
mysql.default_user =

; Default password for mysql_connect() (doesn't apply in safe mode).
; Note that this is generally a *bad* idea to store passwords in this
file.
; *Any* user with PHP access can run 'echo
get_cfg_var("mysql.default_password")
; and reveal this password! And of course, any users with read access
to this
; file will be able to reveal the password as well.
mysql.default_password =

; Maximum time (in secondes) for connect timeout. -1 means no limit
mysql.connect_timeout = 60

; Trace mode. When trace_mode is active (=On), warnings for table/index
scans and
; SQL-Errors will be displayed.
mysql.trace_mode = Off

Thanks for your help!
Dan

Jul 25 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Justin | last post by:
Hi, I am continualy receiving the following type of error in my browser from programs using php/mysql Warning: mysql_connect(): Can't create a new thread (errno 11). If you are not out of...
0
by: W i l l | last post by:
I have Apache 2 parsing and serving PHP files just fine on my winXP box, however, when I try to add some mysql database functionality I get a warning that looks like this: Fatal error: Call to...
6
by: Allen Guan | last post by:
Hello all, I am running MYSQL 4.1.17, PHP 4.3.9 under apache 2.0.52 on solaris. PHP seems to work fine, except that it can't connect to mysql database. I got this error: Warning:...
8
by: Brett | last post by:
I'm developing with CF 5 and SQL Server 2000. I think they are both great products. The major draw is their cost. I don't develop stand alone products because anyone that wants to purchase them...
0
by: Justin | last post by:
Hi, I am continualy receiving the following type of error in my browser from programs using php/mysql Warning: mysql_connect(): Can't create a new thread (errno 11). If you are not out of...
19
by: Michael | last post by:
Hi, I'm trying to do something which should be very simple - connect to the MySQL database. Here is the call, followed by the error msg. $conn = mysql_connect("localhost", "root", ""); ...
14
by: farhan | last post by:
Hi, Please divert me if this is not the right group to be posting this question. I am a Linux client trying to connect to a mysql windows server via php, upon hitting the mysql_connect line...
5
by: cglobal25 | last post by:
Here is the output from phpinfo() on my laptop running windows vista. As you can see mysql is mentioned several times in the output. I'm not sure why i get this error. Php scripts that i save in...
8
by: Kjell Pettersen | last post by:
Hello! I have installed PHP and MySql 5.0 on Win XP. Database created ok. Installation ok. PHP scripts runs ok. But when I am trying some mysql calls in the script I get an "Error 500" from...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.