Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 2003 – Can’t Connect to MySQL Server on ‘Localhost’.

Status
Not open for further replies.

hogatwarthog

Programmer
Jan 20, 2003
1
AU
Hi - I'm a novice trying to learn MySQL and PHP with Kevin Yank’s book.

I have Apache 1.3, PHP 4.3.8 and MySQL 4.1.7 ‘essential’ installed on a Win98SE box that I am using as a developer machine to create a simple contacts database.

Apache runs with PHP and I can recognize PHP but I got the error below in DOS trying to connect to a database (residing in ‘data’ folder). This happens if I enter ‘mysql’ at the MySQL\ bin prompt.

Error 2003 (HY000) Can’t connect to the MySQL server on ‘localhost’ (10061).

The MySQL command line client asks for my password which, when entered, displays an error message of some sort for a microsecond and the DOS screen disappears. At no point does MysQL appear in the Task Manager.

The original, clean installation of MySQL ‘essential’ seemed fine and I got the >msql prompt but something occurred after a day or two to create this error. Even when it was working, no PHP ‘connect’ scripts worked and a similar ‘can’t connect’ error message appeared.

I have tried uninstalling and reinstalling the ‘essential’ package and other versions of MySQL but get the same error. I don’t seem to get a ‘clean’ reinstallation because the installation still refers to some files left behind – ‘Start Service’ and ‘Apply Security Settings’ are now greyed out on the final MySQL install screen as if they still exist. Various combinations of install options all yield the same result.

The problem would appear to be a corrupt MySQL installation, a ‘dirty’ reinstall, a conf. file setting or perhaps a problem with Apache.

I have been through the sections on the MySQL manual that refer to this error but the symptoms seem to be different here and none of the suggestions apply. ‘phpinfo’ lists MySQL but with ‘no value’ against host, password, port, socket and user. The ‘my.ini’ in the Windows folder seems correct.

In the Win 98 ODBC settings the computer name is ‘localhost’ and the Port No., 1433. Using the correct U/N and PWD to connect to the SQL server, an error – SQL state: 01000; Server Error: 10061, TCP/IP sockets open – connect; Connection failed, SQL state: 08001, SQL Server Error: 11, TCP/IP General Network error.

I can’t see any reference to ‘hosts’ in the System 32 folder but there is a ‘hosts.sam’ under Windows that lists ‘localhost 127.0.0.1.

Any help to get past this roadblock would be more than welcome.

Thanks

Martin Evers



 
default port for mysql is 3306 (1433 is ms sql)

is there a user set up with the credentials that you are supplying for the mysql server?

Bastien

Cat, the other other white meat
 
After installing MySQL Ver 4.1.7 on Win 2000 without incident I start the engine which shows:
....
mysqld: ready for connections.
Version: '4.1'7' socket: '' port: 0 Source Distribution

Perhaps not surprisingly, when I try to do "mysql" to get the command prompt it reports that a connection could not be made on port 3306, Connect Failed.

I don't know why the seemingly successful launch of the server says listening on port: 0

I kept the standard default of 3306 when stepping thru the
configuration session and the [client] portion of my.ini
shows the port setting of: port=3306

mysqld does show as a task in task manger as: MySQL 4.1 running ???
 
ummm what you can try is go to control panal admin tools then services to see if mysql is running under the services menu. mine wasnt so i just installed somthing called phptriad or somthing which has all the tools you need to build a php site including mysql and it worked
 
Martin - I've posted the same problem, hoping a geek who missed yours might come along. I am trying to run ISS as my localhost. IIS is working now.

I've also subscribed to Kevin Yank's book. He recommends finding answers at his sitepoint site, but I don't see anything there for MySql.

If you find an answer, I'd be keen to hear of it. Cheers
zonkd
 
Go to a command prompt and type "ping localhost". Make sure that localhost resolves to the IP address 127.0.0.1 and that you get replies.

If not, you might need to install Dial-up networking or a NIC in your computer to get it working. I've never figured out how to get TCP/IP installed on a windows box without putting in a NIC and setting it up for TCP/IP.
 
Thanks very much, dalchri. Unfortunately - or fortunately - ping pings as you say, but it still doesn't find MySQL server on localhost. Cheers
 
Is there any chance you've got a firewall up? Windows XP would probably block 3306 by default. If you can, try telnet (IP address) 3306 from a different machine. You should get something like this:
Code:
<
 4.1.7-standard«EROstnId,?=?ggQ?(Gnsw|

Connection to host lost.

Here is an example what you should NOT get:
Code:
C:\Documents and Settings\chrisdp>telnet 102.168.0.101 3306
Connecting To 102.168.0.101...Could not open connection to the host, on port 3306: Connect failed

Make certain that MySQL is running. In the task manager, the name of the process should be mysqld-nt.exe for NT/2K/XP. I believe the name is mysqld-opt.exe for Windows 9x/Me if memory serves me right.

If you don't see the process, try running it yourself manually from windows explorer or the command prompt by running the appropriate exe for your platform from the bin folder.

If the correct process never appears in the task manager, its probably got some sort of error on startup. In any event, you may want to look at the .err file in your datadir. The name depends on the network name of your computer. For example, a computer called mysql would have the file mysql.err in the datadir.

This error file will give you more to go on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top