mysql not running on localhost

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
atrichtch
Forum Newbie
Posts: 18
Joined: Sun Apr 03, 2011 4:57 pm

mysql not running on localhost

Post by atrichtch »

Hi,

I have a weird problem with MySQL queries- they execute on the remote server, but not on the localhost.

Code: Select all

mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());

$data = mysql_query($query) or die(mysql_error()); 
The mysql_error never shows up, but the query doesn't fetch anything. What could cause it?
Thanks.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: mysql not running on localhost

Post by califdon »

What DOES happen? Do you have any indication that your web server is running, your PHP is running, your MySQL is running? Check those things first. Use temporary echo statements to see if anything is being sent to your browser, such as echo "Hello!"; and assign the mysql connection to a variable so you can echo whether the variable has been set.
atrichtch
Forum Newbie
Posts: 18
Joined: Sun Apr 03, 2011 4:57 pm

Re: mysql not running on localhost

Post by atrichtch »

Apache server is running (indicated in the bottom right-hand corner of my screen); the page does get output (everything except for the SQL data does show up), MySQL is running (otherwise it would give MySQL connection errors), but the query doesn't fetch anything when I'm certain it should (it does return several record in the command line). So what could be wrong? The browser configuration?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: mysql not running on localhost

Post by califdon »

atrichtch wrote:Apache server is running (indicated in the bottom right-hand corner of my screen); the page does get output (everything except for the SQL data does show up), MySQL is running (otherwise it would give MySQL connection errors), but the query doesn't fetch anything when I'm certain it should (it does return several record in the command line). So what could be wrong? The browser configuration?
OK, then I would check the query, itself, and run the same query from the command line. It's certainly possible that, with the data in your table(s) on your localhost, and the requirements of the query, there are just no rows to return. I don't think there's anything in your browser configuration that could result in that.
atrichtch
Forum Newbie
Posts: 18
Joined: Sun Apr 03, 2011 4:57 pm

Re: mysql not running on localhost

Post by atrichtch »

OK, my problem was using the empty string as a password instead of not specifying it at all.
User avatar
waytoecommerce
Forum Newbie
Posts: 16
Joined: Tue Apr 12, 2011 11:47 am

Re: mysql not running on localhost

Post by waytoecommerce »

if every thing is running then i am sure your port has been allotted to other software installed in your system. In this condition you have to edit this file. Please look below : -

Just go to X:\wamp\bin\apache\apache2.2.8\conf\httpd.conf

and search for "Listen 80" change 80 to whatever you want ....

hope it will help...

thanks!
waytoecommerce.com
atrichtch
Forum Newbie
Posts: 18
Joined: Sun Apr 03, 2011 4:57 pm

Re: mysql not running on localhost

Post by atrichtch »

Thanks for the reply, waytoe.

I thought it's a small syntax error, but it wasn't. Apparently the browser can't find the server localhost, giving the following error: php_network_getaddresses: getaddrinfo failed: No such host is known. I'll play around with the configuration; there ought to be a solution.
Thanks again.
atrichtch
Forum Newbie
Posts: 18
Joined: Sun Apr 03, 2011 4:57 pm

Re: mysql not running on localhost

Post by atrichtch »

OK, what did solve the problem was opening my.ini and realize it runs on port 3307. So the first parameter in the connection should've been "localhost:3307" and not "localhost" since the server assumes it to be port 80.

In general, using Apache server is a little tricky. For instance, if you want to execute desktop applications remotely, you need to go to services.mcs in the System folder and check the "allow interaction with desktop" box in the properties menu; otherwise the browser hangs (see my other thread).
Post Reply