Click to See Complete Forum and Search --> : Can't Connect To Database
Paul Jr
12-30-2003, 02:03 PM
Well, I picked up the PHP and MySQL book I got for christmas and started reading. I downloaded and installed MySQL 4.0.17 for windows, per my book's instructions. Now, through the commant prompt, I attempted to connect to my Data base, so I could create a test DB, once again, per my book's instruction. Yet, when I try to connect, I get this error:
MYSQLADMIN: connect to server at 'localhost' failed
error: 'Can't connect to MySQL server on 'localhost' (10061)'
Check that mysqld is running on localhost and that the port is 3306.
You can check this by doing 'telnet localhost 3306'
I can provide you with the exact instructions from my book, plus any other information you might need.
The book I'm using is "PHP fast&easy web development" edition two.
Thanks :).
***EDIT***
As an after-thought, I figured it might be important, so here is the "my.ini" setup file, accessed via WinMySQL Admin
#This File was made using the WinMySQLAdmin 1.3 Tool
#11/4/2003 12:29:41 AM
#Uncomment or Add only the keys that you know how works.
#Read the MySQL Manual for instructions
[mysqld]
basedir=C:/mysql
#bind-address=127.0.0.1
datadir=C:/mysql/data
#language=C:/FoxServ/mysql/share/your language directory
#slow query log#=
#tmpdir#=
#port=3306
#set-variable=key_buffer=16M
[WinMySQLadmin]
Server=C:/MYSQL/bin/mysqld-opt.exe
user=Paul Jr
password=******
Did you try this?
You can check this by doing 'telnet localhost 3306'
Paul Jr
12-30-2003, 02:34 PM
I did indeed, and ended up with:
C:\MYSQL\BIN>telnet localhost 3306
Connecting To localhost...Could not open connection to the host, on port 3306: Connect failed
AdamBrill
01-02-2004, 01:00 PM
Try connecting using the regular mysql command. To connect, use the root user. The command should look like this(from your mysql/bin directory):
mysql -u root -p
then, it will ask you for the password; type it in. If you didn't set the password on the root user, it might not have a password, in which case you would connect like this:
mysql -u root
Once that connects, you should be able to use any mysql command there. To create a database, use this:
CREATE DATABASE `databasename`;
Also, PHPMyAdmin (http://www.phpmyadmin.net) is extremely helpful for database use. :)
Paul Jr
01-07-2004, 08:04 PM
Eek! I need to start paying a bit more attention. I didn't even see this :o :o :o
Sorry about that. I'll try it out tomorrow and see if it works, thanks :) .
Paul Jr
01-08-2004, 06:08 PM
Sorry for opening this up again, but I tried Adam's suggestion and ended up with:
C:\MYSQL\BIN>mysql -u root -p
Enter password: ******
ERROR 2003: Can't connect to MySQL server on 'localhost' (10061)
C:\MYSQL\BIN>
"My.ini file"
#This File was made using the WinMySQLAdmin 1.3 Tool
#11/4/2003 12:29:41 AM
#Uncomment or Add only the keys that you know how works.
#Read the MySQL Manual for instructions
[mysqld]
basedir=C:/mysql
#bind-address=193.100.100.2
datadir=C:/mysql/data
#language=C:/FoxServ/mysql/share/your language directory
#slow query log#=
#tmpdir#=
#port=3306
#set-variable=key_buffer=16M
[WinMySQLadmin]
Server=C:/MYSQL/bin/mysqld-opt.exe
user=Paul Jr
password=******
AdamBrill
01-08-2004, 09:56 PM
Due to the error that you recieved, my guess is that the mysql server is not running. To start it, you have a few options... ;)
1. Use the pretty looking windows app to do it.
2. Use the lame looking dos to do it. :p
If you choose 1, open your mysql/bin folder and run the winmysqladmin file. It should start the server for you and automatically minus itself down to the tray(it should have a little green light saying that the server is running). After you run this program, you can open it up and close it if you want to(the mysql server will remain running), and you can also use mysql through the dos prompt as I have shown.
If you choose 2, then you made a poor choice. Go back and review and make sure you don't want to choose 1. :p Basically you would start the server yourself(the server file is myslqd-nt.exe), but I highly suggest letting the windows app do it for you. ;)
Hope that works for you! Let me know if you have any more problems with it. ;)
Paul Jr
01-08-2004, 10:12 PM
Originally posted by AdamBrill
Due to the error that you recieved, my guess is that the mysql server is not running.
Unfortunately, that is incorrect. :(
The MySQL Server is indeed running.
Which makes me quite *confuzzled.
*Extremely Confused.
eagle0
04-14-2004, 10:07 AM
I'm having the exact same problem. Except I don't get a green light therefor I'm not connected and it seems I can't get it connected at all.. ??
DaiWelsh
04-14-2004, 10:25 AM
You could try using 127.0.0.1 and/or the IP address specified in the my.ini (e.g. 193.100.100.2) it may be that 'localhost' is not resolving to the correct IP to make mysql happy...?
eagle0
04-14-2004, 01:00 PM
I do have an ip addy assigned in the my.ini (192.168.1.3)
As well as a username and pass (lets use test/test for example) I've tried the about listed help steps as to telneting the machine with port 3306 but everything comes back to the server must be connected within the winmysqladmin.
I've got to be over looking something stupid on my part regarding possibly usernames or passwords. I'm just not realy sure..
:confused:
eagle0
04-14-2004, 01:09 PM
Ok I was able to get connected I think (the green light on) by typing in mysqld --console.
Now I'm trying to get a forum board running (.php) and it shows as just text in the browser.