zack_falcon
zack_falcon

Reputation: 4386

MySQL Error 2003: Can't connect to MySQL server on 'localhost'

I've been given the task of running a program that relies on a MySQL database, specifically, the 3.23.42 version. I have to install MySQL, run a .batch file that reads an SQL file (to create the required tables and such), then run the program. Seems simple enough.

I got as far as installing MySQL. I was expecting it to ask username and passwords and such, as was my experience with installing SQL Server and MySQL version 5 (and later), but it needed nothing from me. Attempts to run the .batch file, however, yields the error:

"MySQL Error 2003: Can't connect to MySQL server on 'localhost' "

So I ran Command prompt as an administrator, went to the MySQL directory, and ran "mysql". It gave me the same error as above.

Running the commands "mysqld-nt" or "mysqld" didn't do anything, so I'm assuming there's another problem at work here. Neither did I find any 'mysql' in the running services or process.

At this point, it doesn't matter if the program runs or not. I need the database up and running first.

Although I've used MySQL before, I can't say I have that much experience with it, and it had always been up and running already; this is the first time I'm deploying it myself.

Of note is that: I haven't tried to reinstall the program yet, although I'm not sure if it will fix anything. I've installed MyODBC-3.15.05, if it means anything (part of the instructions). I'm using Windows 7, 32-bit (I have heard MySQL doesn't like to play nice with Windows 7). I'm using this setup as both the server and the client; had the entire process been successful, I was to do the same thing on another computer. No computer actually uses another as a server. I don't exactly know what services to look for in the services list.

Is there anything I can do to fix this problem?

Upvotes: 2

Views: 21442

Answers (7)

matthewpark319
matthewpark319

Reputation: 1263

Open the MySQL Installer and click on where it says "reconfigure" next to "MySQL Server"

Upvotes: 0

neo.abi1000
neo.abi1000

Reputation: 59

if it is showing error 2003 (HY000): Can't connect to MySQL server on localhost (10061) than 1.search services.msc in run 2.goto mysql properties 3.copy the mysql service name 4.start cmd as administrator 5.write: net start mysqlservicename .i.e mysql57 or etc it will show mysql is starting.

Upvotes: -1

TheGoodGuy
TheGoodGuy

Reputation: 1

I'm not sure if the services application is on other windows or not but if you use Windows 7, you are lucky. The easiest method is to open Start panel,in the search box,type services and hit enter.Now scroll down till you find the mysql service.In the latest version, it is named MySQL57. Right click on it and click on start. Now you are good to use MySQL. However,you will have to perform this step every time the windows starts.

Upvotes: 0

zack_falcon
zack_falcon

Reputation: 4386

Well, I don't exactly know what caused this issue in the first place, but I was able to find a way to solve it. A helpful, if old - perfect in this case - tutorial I found on the web, that hopefully can help others with the same problem.

Tutorial: Install MySQL 4.0 - Windows, by Dr. Thomas E. Hicks Computer Science Department Trinity University

Link Here

Upvotes: 0

Devart
Devart

Reputation: 122002

  1. Check in Task Manager that mysql server is started.
  2. Check if you can connect to the server, run telnet <hostname> <portnumber>, e.g.:

    telnet localhost 3306

  3. If you could not connect, try to find server properties (check port number), also check your firewall.

Upvotes: 2

David Newcomb
David Newcomb

Reputation: 10943

Early versions of the MySQL installer didn't set up the windows service at all. You might have to do it by hand.

http://dev.mysql.com/doc/refman/5.1/en/windows-start-service.html

When the service is installed you should be able to enter the following command to start the service.

net start mysql

Then all you need is to open a command window and type the following to get you into the MySQL command line where you can start writing your own queries.

mysql -uroot

I'm not terribly up on Microsoft SQL Server's flavour of SQL but I think that if you are used to using it then you might find it difficult to "get into" MySQL.

Here's a simple tutorial that gives an overview of MySQL and creating queries. http://www.bigsoft.co.uk/blog/index.php/2012/10/04/sql-for-beginners

Upvotes: 5

hd1
hd1

Reputation: 34677

Look for the file my.ini and add bind-address = 0.0.0.0 in the [mysqld] stanza.

Upvotes: 0

Related Questions