By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,829 Members | 1,798 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,829 IT Pros & Developers. It's quick & easy.

Connect to MySQL

P: n/a
Hi,

PHP 4.3.4 installed manually from package *.zip and Apache 2. I have a
problem with this simple code:

<?php
$link = mysql_connect("127.0.0.1","","")
or die("Could not connect: " . mysql_error());
echo "Connected successfully";
mysql_close($link);
?>

And this error occurs:

Warning: mysql_connect(): Can't connect to MySQL server on '127.0.0.1'
(10061) in C:\usr\Apache2\htdocs\friko.pl\index.html on line 18
Could not connect: Can't connect to MySQL server on 'localhost' (10061)

The settings are:

Active Persistent Links 0
Active Links 0
Client API version 3.23.49

Directive Local Value Master Value
mysql.allow_persistent On/On
mysql.connect_timeout 60/60
mysql.default_host localhost/localhost
mysql.default_password no value/no value
mysql.default_port no value/no value
mysql.default_socket no value/no value
mysql.default_user no value/no value
mysql.max_links Unlimited/Unlimited
mysql.max_persistent Unlimited/Unlimited
mysql.trace_mode Off/Off

Thanks for any hints :--|

--
pozdr. Dygi [GG 1027078]
dygimail(at)poczta(dot)fm
Jul 17 '05 #1
Share this Question
Share on Google+
20 Replies


P: n/a
On 2004-02-04, Mr Dygi <dy********@SPAMpoczta.fm> wrote:
Hi,

PHP 4.3.4 installed manually from package *.zip and Apache 2. I have a
problem with this simple code:

<?php
$link = mysql_connect("127.0.0.1","","")
or die("Could not connect: " . mysql_error());
echo "Connected successfully";
mysql_close($link);
?>

And this error occurs:

Warning: mysql_connect(): Can't connect to MySQL server on '127.0.0.1'
(10061) in C:\usr\Apache2\htdocs\friko.pl\index.html on line 18
Could not connect: Can't connect to MySQL server on 'localhost' (10061)

Have you installed mysql? and is it running?

--
http://home.mysth.be/~timvw
Jul 17 '05 #2

P: n/a
Tim Van Wassenhove <eu**@pi.be> wrote in news:bvqth6$vnk5c$2@ID-
188825.news.uni-berlin.de:
Have you installed mysql? and is it running?


Here I have another problem. I think, yes. I have installed MyODB 3.51.06
fo Windows with small configure problems. I have done this with
instructions from MyQSL Reference Manual for version 4.0.5 chapter 8.3.1
and 8.3.2.

But I'am not sure I should execute these section:

* To make a connection to a Unix box from a Windows box, with an ODBC
application (one that doesn't support MySQL natively), you must first
install MyODBC on the Windows machine.
* The user and Windows machine must have the access privileges to the MySQL
server on the Unix machine. This is set up with the GRANT command. See
section 4.3.1 GRANT and REVOKE Syntax.
+ You must create an ODBC DSN entry as follows:
+ Open the Control Panel on the Windows machine.
+ Double-click the ODBC Data Sources 32-bit icon.
+ Click the tab User DSN.
+ Click the button Add.
+ Select MySQL in the screen Create New Data Source and click the Finish
button.
* The MySQL Driver default configuration screen is shown. See section 8.3.2
How to Fill in the Various Fields in the ODBC Administrator Program.
* Now start your application and select the ODBC driver with the DSN you
specified in the ODBC administrator

I have done the section but something is still wrong. I can do some screen-
prints to show You what I have done, if you need to see it.

ps
I think I have some mistakes done about installing and configuring MyODBC.

--
pozdr. Dygi [GG 1027078]
dygimail(at)poczta(dot)fm
Jul 17 '05 #3

P: n/a
On 2004-02-04, Mr Dygi <dy********@SPAMpoczta.fm> wrote:
Tim Van Wassenhove <eu**@pi.be> wrote in news:bvqth6$vnk5c$2@ID-
188825.news.uni-berlin.de:
Have you installed mysql? and is it running?


Here I have another problem. I think, yes. I have installed MyODB 3.51.06
fo Windows with small configure problems. I have done this with
instructions from MyQSL Reference Manual for version 4.0.5 chapter 8.3.1
and 8.3.2.


I'm not sure, but i think MyODB provides a driver to let ODBC talk with
your MySQL server.

Thus my question remains: Have you installed mysql server? and is it
running? :)

--
http://home.mysth.be/~timvw
Jul 17 '05 #4

P: n/a
"Mr Dygi" <dy********@SPAMpoczta.fm> wrote in message
news:Xn******************************@127.0.0.1...
$link = mysql_connect("127.0.0.1","","")


Make sure that your MySQL is running and does have the user with no-name and
no-password.

Jul 17 '05 #5

P: n/a
Tim Van Wassenhove <eu**@pi.be> wrote in news:bvrb4s$v7eq1$2@ID-
188825.news.uni-berlin.de:
I'm not sure, but i think MyODB provides a driver to let ODBC talk with
your MySQL server.
Thus my question remains: Have you installed mysql server? and is it
running? :)


Oh noooo... What a stupid. I was reading too fast and misunderstand the
text: "Note that MySQL and ODBC support is now built in, so no dll is
needed for it." from php package. I thought it is included like a module or
sth like that :--|

Ok. I've found it. Is this correct file:

http://www.mysql.com/get/Downloads/M...mysql-3.23.58-
win.zip/from/ftp://sunsite.icm.edu.pl/pub/unix/mysql/

About 13MB ;--[

--
pozdr. Dygi [GG 1027078]
dygimail(at)poczta(dot)fm
Jul 17 '05 #6

P: n/a
Tim Van Wassenhove <eu**@pi.be> wrote in news:bvrb4s$v7eq1$2@ID-
188825.news.uni-berlin.de:
I'm not sure, but i think MyODB provides a driver to let ODBC talk with
your MySQL server.


You were right. I didn't have SQL Server installed. I have found 3.21.29a -
for win95 version on the CD form one of the old PC Magazines. I hope it
will not be a very problemous software (version) becasuse of my WinXP ;--)

I am newbie so i don't need very new functions of the sql database. What
you think?

ps
Thanks. You've pointed me in right direction.

--
pozdr. Dygi [GG 1027078]
dygimail(at)poczta(dot)fm
Jul 17 '05 #7

P: n/a
In message <Xn******************************@127.0.0.1>, Mr Dygi
<dy********@SPAMpoczta.fm> writes
You were right. I didn't have SQL Server installed. I have found
3.21.29a - for win95 version on the CD form one of the old PC
Magazines. I hope it will not be a very problemous software (version)
becasuse of my WinXP ;--)
This is a very old release - they MySQL site is recommending V4.1 for
new developments. On XP (and 2K & NT) it runs as a service (starts
automatically when the PC boots) which is probably what you want. I am
not using ODBC to connect to it on my PC either - presumably the PHP
functions are picking up information in the configuration file which
includes which TCP port to communicate with the server on.

I am newbie so i don't need very new functions of the sql database.
What you think?


I do think you should use an up-to-date version. You don't have to get
very far with SQL to find you want some of the features in it that are
not in 3.21 such as subqueries. I also wish that Informix had 'CREATE
TABLE x LIKE y'.

Lots more at:

http://www.mysql.com/doc/en/Nutshell_4.1_features.html
--
Five Cats
Email to: cats_spam at uk2 dot net
Jul 17 '05 #8

P: n/a
Five Cats <ca*******@[127.0.0.1]> wrote in
news:Wt**************@[127.0.0.1]:
This is a very old release - they MySQL site is recommending V4.1 for
new developments. On XP (and 2K & NT) it runs as a service (starts
automatically when the PC boots) which is probably what you want.
Yes. I configured it as service. It works in system background.
I am
not using ODBC to connect to it on my PC either - presumably the PHP
functions are picking up information in the configuration file which
includes which TCP port to communicate with the server on.
Hm. I've installed MySQL as service (mysqld) so I think php is not using
this way to connect to MySQL. Right? How can I check it?
I do think you should use an up-to-date version. You don't have to get
very far with SQL to find you want some of the features in it that are
not in 3.21 such as subqueries.
Yes. Yesterday I read some tutorials and I saw this version have not some
basic feautures that later have.
http://www.mysql.com/doc/en/Nutshell_4.1_features.html


Thanks a lot. I've already started to download newer version.

--
pozdr. Dygi [GG 1027078]
dygimail(at)poczta(dot)fm
Jul 17 '05 #9

P: n/a
In message <Xn******************************@127.0.0.1>, Mr Dygi
<dy********@SPAMpoczta.fm> writes
Five Cats <ca*******@[127.0.0.1]> wrote in
news:Wt**************@[127.0.0.1]:
This is a very old release - they MySQL site is recommending V4.1 for
new developments. On XP (and 2K & NT) it runs as a service (starts
automatically when the PC boots) which is probably what you want.
Yes. I configured it as service. It works in system background.


Have you tested it by connecting & so on from a DOS box?
I am
not using ODBC to connect to it on my PC either - presumably the PHP
functions are picking up information in the configuration file which
includes which TCP port to communicate with the server on.
Hm. I've installed MySQL as service (mysqld) so I think php is not using
this way to connect to MySQL. Right? How can I check it?


It is connecting to the service through a TCP port, as specified in the
my.ini file. Of course it might depend on what PHP commands you are
using - I'm assuming you are using the specific MySQL ones (see
http://www.php.net/manual/en/ref.mysql.php). The entry for
mysql_connect makes it quite explicit it's connection via a TCP port
(the default is localhost:3306 but best see the manual page,
http://www.php.net/manual/en/functio...l-connect.php), but if you are
using the ODBC functions then you would need an appropriate ODBC driver
installed. There is a big assumption on my part here, which is that you
*can* use ODBC to access a MySQL database - it's not mentioned in the
manual (http://www.php.net/manual/en/ref.odbc.php) but I know there is a
driver and I've managed to use it to get data into Excel before now.
This could well be an assumption too far.
I do think you should use an up-to-date version. You don't have to get
very far with SQL to find you want some of the features in it that are
not in 3.21 such as subqueries.
Yes. Yesterday I read some tutorials and I saw this version have not some
basic feautures that later have.


;-)
http://www.mysql.com/doc/en/Nutshell_4.1_features.html


Thanks a lot. I've already started to download newer version.


The manuals (MySQL & PHP) might be a useful download as well if you
don't already have them!

--
Five Cats
Email to: cats_spam at uk2 dot net
Jul 17 '05 #10

P: n/a
Five Cats <ca*******@[127.0.0.1]> wrote in
news:SI**************@[127.0.0.1]:
Have you tested it by connecting & so on from a DOS box?
I've installed it in DOS box and just learned some basics. Also tested it
with:

telnet localhost 3306

It's great thing. I can now study basics operations on MySQL database
without getting online.
It is connecting to the service through a TCP port, as specified in the
my.ini file. Of course it might depend on what PHP commands you are
using - I'm assuming you are using the specific MySQL ones (see
http://www.php.net/manual/en/ref.mysql.php). The entry for
mysql_connect makes it quite explicit it's connection via a TCP port
(the default is localhost:3306 but best see the manual page,
http://www.php.net/manual/en/functio...l-connect.php), but if you are
using the ODBC functions then you would need an appropriate ODBC driver
installed. There is a big assumption on my part here, which is that you
*can* use ODBC to access a MySQL database - it's not mentioned in the
manual (http://www.php.net/manual/en/ref.odbc.php) but I know there is a
driver and I've managed to use it to get data into Excel before now.
This could well be an assumption too far.
I don't understand. I connect to MySQL like you said with mysql_connect and
using localhost:3306. I have also installed ODBC driver, because of the
instructions. I don't understand the part of the text about getting data
into Excel.
The manuals (MySQL & PHP) might be a useful download as well if you
don't already have them!


Yes, there are. I've both on my HDD. Helps very much. Especially tutorial
for newbies ;--D

ps
For what is the ODBC Driver if I can connect to the MySQL database over
TCP/IP? For what is it genetally? For connecting to the MySQL database
without installed TCP/IP?

--
pozdr. Dygi [GG 1027078]
dygimail(at)poczta(dot)fm
Jul 17 '05 #11

P: n/a
In message <Xn******************************@127.0.0.1>, Mr Dygi
<dy********@SPAMpoczta.fm> writes
Five Cats <ca*******@[127.0.0.1]> wrote in
news:SI**************@[127.0.0.1]:
Have you tested it by connecting & so on from a DOS box?
I've installed it in DOS box and just learned some basics. Also tested it
with:

telnet localhost 3306

It's great thing. I can now study basics operations on MySQL database
without getting online.
It is connecting to the service through a TCP port, as specified in the
my.ini file. Of course it might depend on what PHP commands you are
using - I'm assuming you are using the specific MySQL ones (see
http://www.php.net/manual/en/ref.mysql.php). The entry for
mysql_connect makes it quite explicit it's connection via a TCP port
(the default is localhost:3306 but best see the manual page,
http://www.php.net/manual/en/functio...l-connect.php), but if you are
using the ODBC functions then you would need an appropriate ODBC driver
installed. There is a big assumption on my part here, which is that you
*can* use ODBC to access a MySQL database - it's not mentioned in the
manual (http://www.php.net/manual/en/ref.odbc.php) but I know there is a
driver and I've managed to use it to get data into Excel before now.
This could well be an assumption too far.


I don't understand. I connect to MySQL like you said with mysql_connect and
using localhost:3306. I have also installed ODBC driver, because of the
instructions.


I'm not sure which instructions those are, but I doubt you are using the
ODBC driver.
I don't understand the part of the text about getting data
into Excel.
Excel was an aside - just an example that it is possible to get data out
of MySQL with an ODBC driver. I'm really more interested in the
instructions which tell you to install ODBC, as I'm darned sure it's not
on my PC and that's working just fine, and I'm just as sure that the
installation instructions I got with MySQL didn't make any reference to
ODBC.

The manuals (MySQL & PHP) might be a useful download as well if you
don't already have them!
Yes, there are. I've both on my HDD. Helps very much. Especially tutorial
for newbies ;--D

ps
For what is the ODBC Driver if I can connect to the MySQL database over
TCP/IP? For what is it genetally? For connecting to the MySQL database
without installed TCP/IP?


There is stuff about ODBC at::

http://www.mysql.com/products/myodbc/
You might also want to explore the FAQs about it:

http://www.mysql.com/products/myodbc/faq_toc.html

But basically it's an API which many programs 'know' about which allows
them to communicate with databases. PHP, however, can communicate more
directly with MySQL via sockets.


--
Five Cats
Email to: cats_spam at uk2 dot net
Jul 17 '05 #12

P: n/a
Five Cats <ca*******@[127.0.0.1]> wrote in
news:rC**************@[127.0.0.1]:
Excel was an aside - just an example that it is possible to get data out
of MySQL with an ODBC driver. I'm really more interested in the
instructions which tell you to install ODBC, as I'm darned sure it's not
on my PC and that's working just fine, and I'm just as sure that the
installation instructions I got with MySQL didn't make any reference to
ODBC.
Yhm. I can't find it now but I'am sure they were somewhere. I think it was
one of the off-line www sites which I decided to save (because of
information how to install and configure) for further installing
Apache2/PHP4 server. I'll try to uninstall ODBC and check if there are no
errors. Maybe tomorrow evening because of physics exam I have to pass :--|
http://www.mysql.com/products/myodbc/
You might also want to explore the FAQs about it:
http://www.mysql.com/products/myodbc/faq_toc.html
I'll check it. Thanks.
But basically it's an API which many programs 'know' about which allows
them to communicate with databases. PHP, however, can communicate more
directly with MySQL via sockets.


I have some questions here but I think It'll be better to ask when I end
exploring FAQ sources.

--
pozdr. Dygi [GG 1027078]
dygimail(at)poczta(dot)fm
Jul 17 '05 #13

P: n/a
Five Cats <ca*******@[127.0.0.1]> wrote in
news:rC**************@[127.0.0.1]:
http://www.mysql.com/products/myodbc/
http://www.mysql.com/products/myodbc/faq_toc.html


Ok. I've looked at this pages. But I still do not understand for what I had
to install ODBC?! I don't want to use connection between M$ Access and
Excel with MySQL. Uninstalling.

--
pozdr. Dygi [GG 1027078]
dygimail(at)poczta(dot)fm
Jul 17 '05 #14

P: n/a
In message <Xn******************************@127.0.0.1>, Mr Dygi
<dy********@SPAMpoczta.fm> writes
Five Cats <ca*******@[127.0.0.1]> wrote in
news:rC**************@[127.0.0.1]:
Excel was an aside - just an example that it is possible to get data out
of MySQL with an ODBC driver. I'm really more interested in the
instructions which tell you to install ODBC, as I'm darned sure it's not
on my PC and that's working just fine, and I'm just as sure that the
installation instructions I got with MySQL didn't make any reference to
ODBC.
Yhm. I can't find it now but I'am sure they were somewhere.


Was it you who posted somewhere else that 'the book they were using told
them to'? If that was the case the book must have been working towards
using MySQL behind stuff that had to use ODBC to connect, which PHP
doesn't.
I think it was
one of the off-line www sites which I decided to save (because of
information how to install and configure) for further installing
Apache2/PHP4 server. I'll try to uninstall ODBC and check if there are no
errors. Maybe tomorrow evening because of physics exam I have to pass :--|
http://www.mysql.com/products/myodbc/
You might also want to explore the FAQs about it:
http://www.mysql.com/products/myodbc/faq_toc.html
I'll check it. Thanks.
But basically it's an API which many programs 'know' about which allows
them to communicate with databases. PHP, however, can communicate more
directly with MySQL via sockets.


I have some questions here but I think It'll be better to ask when I end
exploring FAQ sources.


And when you have done your physics exam....


--
Five Cats
Email to: cats_spam at uk2 dot net
Jul 17 '05 #15

P: n/a
In message <Xn******************************@127.0.0.1>, Mr Dygi
<dy********@SPAMpoczta.fm> writes
Five Cats <ca*******@[127.0.0.1]> wrote in
news:rC**************@[127.0.0.1]:
http://www.mysql.com/products/myodbc/
http://www.mysql.com/products/myodbc/faq_toc.html
Ok. I've looked at this pages. But I still do not understand for what I had
to install ODBC?


You didn't!
! I don't want to use connection between M$ Access and
Excel with MySQL. Uninstalling.


--
Five Cats
Email to: cats_spam at uk2 dot net
Jul 17 '05 #16

P: n/a
Five Cats <ca*******@[127.0.0.1]> wrote in
news:D6**************@[127.0.0.1]:
You didn't!


Yes I did. I have an offline version on my Ccomputer. On the page is
written:

MySQL Connector/ODBC (also known as MyODBC) allows you to connect to a
MySQL database server using the ODBC database API on all Microsoft Windows
and most Unix platforms, including through such applications and
programming environments such as Microsoft Access, Microsoft Excel, and
Borland Delphi.

So I've decided to uninstall ODBC and I did it. I've checked that I can
still connect to the database and... turn back to study my sweet physics
books ;-->

ps
3 ouhrs to exam. Horrible. I couldn't sleep tonight, looking at sheets all
the time ;-->

--
pozdr. Dygi [GG 1027078]
dygimail(at)poczta(dot)fm
Jul 17 '05 #17

P: n/a
Five Cats <ca*******@[127.0.0.1]> wrote in
news:6p**************@[127.0.0.1]:
And when you have done your physics exam....


Ohhhh. I don't think so. I can't leave my hobby for a month. I can do this
for a... day. ONE day. Precisely one night which, at this moment, come to
an end ;-->

--
pozdr. Dygi [GG 1027078]
dygimail(at)poczta(dot)fm
Jul 17 '05 #18

P: n/a
Mr Dygi <dy********@SPAMpoczta.fm> wrote in message news:<Xn******************************@127.0.0.1>. ..
Five Cats <ca*******@[127.0.0.1]> wrote in
news:SI**************@[127.0.0.1]:
Have you tested it by connecting & so on from a DOS box?


I've installed it in DOS box and just learned some basics. Also tested it
with:

telnet localhost 3306

It's great thing. I can now study basics operations on MySQL database
without getting online.
It is connecting to the service through a TCP port, as specified in the
my.ini file. Of course it might depend on what PHP commands you are
using - I'm assuming you are using the specific MySQL ones (see
http://www.php.net/manual/en/ref.mysql.php). The entry for
mysql_connect makes it quite explicit it's connection via a TCP port
(the default is localhost:3306 but best see the manual page,
http://www.php.net/manual/en/functio...l-connect.php), but if you are
using the ODBC functions then you would need an appropriate ODBC driver
installed. There is a big assumption on my part here, which is that you
*can* use ODBC to access a MySQL database - it's not mentioned in the
manual (http://www.php.net/manual/en/ref.odbc.php) but I know there is a
driver and I've managed to use it to get data into Excel before now.
This could well be an assumption too far.


I don't understand. I connect to MySQL like you said with mysql_connect and
using localhost:3306. I have also installed ODBC driver, because of the
instructions. I don't understand the part of the text about getting data
into Excel.
The manuals (MySQL & PHP) might be a useful download as well if you
don't already have them!


Yes, there are. I've both on my HDD. Helps very much. Especially tutorial
for newbies ;--D

ps
For what is the ODBC Driver if I can connect to the MySQL database over
TCP/IP? For what is it genetally? For connecting to the MySQL database
without installed TCP/IP?

Hello Dygi,

You asked...
For what is the ODBC Driver if I can connect to the MySQL database
over
TCP/IP? For what is it genetally? For connecting to the MySQL database
without installed TCP/IP?

Some applications can connect to databases via their native
interfaces. However, other application are not so database specific.
Such applications--and I presume Excel is one of them--need a more
standardized way to connect. This is were ODBC comes into play. It is
an industry wide, standardized set of API calls that allow most,
mainstream applications to connect to most databases. Moreover, if you
develop applications against the ODBC spec, they are free to connect
to MySQL, PostgreSQL, Oracle, Ingres, and just about any other
relational database. Hence, ODBC introduces a degree of freedom.

Finally, I am not immediately familiar with the MySQL ODBC drivers.
Therefore, I'm not the one to tell you whether or not they make socket
(tcp/ip) or shared memory connections. I just know that the drivers my
company produces uses tcp/ip based connections.

Netrista Khatam
Technical Services Manager
OpenLink Software
http://www.openlinksw.com
Product Weblogs:
Virtuoso: http://www.openlinksw.com/weblogs/virtuoso
UDA: http://www.openlinksw.com/weblogs/uda
Universal Data Access & Virtual Database Technology
Jul 17 '05 #19

P: n/a
In message <f1**************************@posting.google.com >, Netrista
Khatam <nk*****@openlinksw.com> writes
<useful stuff snipped>
Hence, ODBC introduces a degree of freedom.

And also a degree of lowest common denominator. However this shouldn't
matter for most applications.

<more useful stuff snipped>
--
Five Cats
Email to: cats_spam at uk2 dot net
Jul 17 '05 #20

P: n/a
nk*****@openlinksw.com (Netrista Khatam) wrote in
news:f1**************************@posting.google.c om:
[cut]
This is were ODBC comes into play.


Thanks a lot.

--
pozdr. Dygi [GG 1027078]
dygimail(at)poczta(dot)fm
Jul 17 '05 #21

This discussion thread is closed

Replies have been disabled for this discussion.