This is really just a PHP question, I think.

Are MySQL and Apache running on the same machine?
What version of MySQL are you running?

Typically, you need a PHP mysql_connect() call including the MySQL
host, username, and password. You only list the host above.

With a default installation of MySQL, which gives you a root user with
no password, you could connect like:
$db = mysql_connect( "localhost", "root", "" );
but hopefully you've already given your root user a password, so put
whatever password that was in there.

Instead of creating the "[EMAIL PROTECTED]" user (I think that PHP will
often run as "nobody", perhaps Apache is set up that way also), create
a user with a username/password and privileges that are sufficient for
what you want to do. Then connect using that information.

Wes



On Wed, 29 Sep 2004 12:43:57 -0500, Andrew Lietzow
<[EMAIL PROTECTED]> wrote:
> Hola, MySQL wizards.
> 
> I'm using LAMP on Fedora Core 2.
> Some kind soul produced a tutorial on the net and the first script,
> <birthdays_create_database.php>, I am trying to use yields an error in
> the browser of:  < Couldn't connect to MySQL >  Here is the script.
> -------------------------------
> <html><head><title>Birthdays Create Database</title></head>
> <body>
> <?php
> $dbhost = 'localhost';
> $link = mysql_connect($dbhost);
> if (! $link)
> die("Couldn't connect to MySQL");
> //create database
> mysql_create_db("mydatabase")or die("Create Error: ".mysql_error());
> mysql_close($link);
> ?>
> </body>
> </html>
> ---------------------------
> I can access all of my databases and tables with phpMyAdmin just fine,
> and I can access them at the command line.  Of course I didn't know
> which user I was when was attempting to execute this php script through
> the browser, so I check my mysqld.log file and it claims I should be
> '[EMAIL PROTECTED]', so I setup this user in the mysql database.
> 
> I tried adding
> $dbuser = 'nobody';
> $dbpass = '';
> to the script but to no avail even though I can access through the
> command prompt with <mysql -u nobody -p> with a <null> password.
> 
> When I do a <ps -elf | grep mysql> the results show a --port=3306 as
> well as 10 connection PID's.   My hello.php script works fine, as do
> other php scripts.
> 
> When I list <netstat -l | grep mysql*> however, the number that gets
> displayed in the column after <STREAM     LISTENING>  and before
> </var/lib/mysql/mysql.sock> is 999269.   I was expecting it to be 3306?
> 
> How do I troubleshoot this <Cannot connect to MySQL> error message?  My
> mysqld.log looks "normal" other than a "Warning: Asked for 196608 thread
> stack, but got 126976>.  The mysql.sock line shows <port: 3306>.
> 
> Any ideas on what to check next?   I'd at a loss.
> 
> TIA
> Andrew L. in the Heartland (not the "Hinterlands")
> 
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
> 
>

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to