?
Solved

Dreamweaver - localhost mySQL database won't connect to my php site

Posted on 2007-12-06
13
Medium Priority
?
6,061 Views
Last Modified: 2013-12-12
I have a php site that has been running off a mySQL database very well.

I want to make some changes to the site but I want to run a testing environment on my local computer.

I'm using a Macintosh running Leopard. I installed MySQL and activated php and have the site running locally except that I can't connect to the local database from my local site. I'm using Dreamweaver to make the connection file. I'm using local host with root and no password.

I used navicat to duplicate the database from what it online. I am able to connect to this database on my localhost and everything seems fine until I try to connect to it using my Dreamweaver. Then it can't locate the database. I checked the settings and they are the same as on Navicat, which sees the database fine.

Any suggestions?

Also I'd like to put a password on the root user. How do I do that?
0
Comment
Question by:mrmyth
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 3
  • +1
13 Comments
 
LVL 3

Expert Comment

by:blckholehorizon
ID: 20425502
to set root password:

mysqladmin -u root password newpassword
0
 
LVL 1

Author Comment

by:mrmyth
ID: 20425717
thanks for the reply

i opened terminal and put in exactly what you typed and it said unknown "mysqladmin: command not found"
0
 
LVL 10

Expert Comment

by:ray-solomon
ID: 20426106
Sounds like you are in a user account and you will need to switch to the root account instead.

type:

su

in the terminal and then the root password.
This should give you permission to use mysqladmin.

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:ray-solomon
ID: 20426215
hmm, I just read that the root user is disabled by default on Mac OS X and you cannot use the su command to switch to root.

Instead use:

sudo

http://www.macdevcenter.com/pub/a/mac/2002/10/22/macforunix.html
0
 
LVL 16

Assisted Solution

by:rbudj
rbudj earned 400 total points
ID: 20427553
Did you start Apache (or other) service?  I use WAMP (search google) for my local testing and it works perfectly with Dreamweaver 8 and CS3.  However, you have navigate through the Start menu to find the link that says "Start Apache"
0
 
LVL 3

Expert Comment

by:blckholehorizon
ID: 20427648
to make sure the services are running, run netstat -a | grep tcp

make sure mysql is running on port 3306 ( or whatever port you have it on), and apache on port 80

after installing apache, it will not start automatically at boot time, until you tell it to do so by adding it as a service.  mysql either (unless you used the gui installer to do so)

if they are running, then make sure there is no firewall prohibiting access to them.
0
 
LVL 1

Author Comment

by:mrmyth
ID: 20427774
All the services seem to be running.

I put a password on the root, but it seems when I use Navicat to look at my mySQL database, and use the username root, it still has no password.

My local website still can't access the MySQL database for some strange reason, but Navicat has no problem accessing the database.

I try to connect to it in Dreamweaver and it says "unknown error"

I get this
"Warning: mysql_pconnect() [function.mysql-pconnect]: Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) in /Libarry/WebServer/Documents/MYWEBSITEFOLDER/Connections/conn_WEBSITE.php on line 9."

I don't think the firewall would have anything to do with it since it's local right?

0
 
LVL 3

Accepted Solution

by:
blckholehorizon earned 800 total points
ID: 20428249
are you using an options file for connections?  that could explain why certain connections work, and some don't.  Try connecting over a TCP/IP socket instead of a socket file. also use 'localhost' instead of the IP address for a tcp/ip connection.

If still using a socket file, do the connecting programs have the rights to access the socket file if you are using?
0
 
LVL 1

Author Comment

by:mrmyth
ID: 20433265
I got into a whole thing with the socket file and it seems to be getting closer.

Now it appears that the local website is trying to access the database, but it still can't.

I'm not getting the error that says it can't find the mysql.sock file

I followed these directions that I found:
"Bring the mysql.sock to PHP
One problem that has come about with MySQL and Leopard is the location of the mysql.sock file. Previously, the default location for this file was in the /tmp directory. That location has now moved to the /var/mysql directory. PHP will look for it there. Unfortunately, the default location from the MySQL will still place it in the old location. We can fix this by creating a my.cnf configuration file in the /etc directory. Save a file with the following contents to /etc/my.cnf:

[client]
socket = /var/mysql/mysql.sock

[mysqld]
socket = /var/mysql/mysql.sock

In the terminal window, type the following commands to create the directory for the sock file:

sudo mkdir /var/mysql
sudo chown _mysql /var/mysql"

Now I still can't connect to the database when I try to add it in Dreameaver.
I get "an unidentified error has occured"


0
 
LVL 1

Author Comment

by:mrmyth
ID: 20433288
As far as Dreamweaver goes, I still can't get it to open that database, but when I put in all the pertinent data the connection does occur at the website level.

I was able to configure the php to work on the localhost by following the directions outlined here

http://www.procata.com/blog/archives/2007/10/28/working-with-php-5-in-mac-os-x-105/

especially the section that I recounted above

The Dreamweaver problem is still happening where it says "an unidentified error has occurred" when I try to connect to the database from within Dreamweaver.
0
 
LVL 10

Assisted Solution

by:ray-solomon
ray-solomon earned 800 total points
ID: 20433336
Read the mysql manual for mac os x installation and also read all the user comments for tips.
http://dev.mysql.com/doc/refman/5.0/en/mac-os-x-installation.html

There is a dreamweaver comment in the user comments as well.




I would recommend creating a new php file then access it in your browser if you have apache and php working and configured properly on the computer.  This connection code is for testing purposes only to see what specific error messages are returned. It is helpful in correcting basic connection mistakes.

<?php

define('DB_HOST', 'localhost'); // stays as localhost
define('DB_USERNAME', 'your-database-username');
define('DB_PASSWORD', 'your-database-password');
define('DB_NAME', 'your-database-name');

@mysql_connect(DB_HOST,DB_USERNAME,DB_PASSWORD) or die(mysql_error());
@mysql_select_db(DB_NAME) or die(mysql_error());

?>
0
 
LVL 1

Author Comment

by:mrmyth
ID: 20451705
Thanks for the advice. The final step of getting it to work was just to make sure that I set a testing site. I made it the same as the testing folder on my computer that I'm using and Dreamweaver can now connect.
If I would have just read the steps in the database connection box I wouldn't have had this final problem.


0
 
LVL 1

Author Comment

by:mrmyth
ID: 20451738
In retrospect I think I should have just downloaded MAMP to properly setup the LAMP server on my mac. I assume it would resolve some of these problems.
0

Featured Post

WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question