Koozali.org: home of the SME Server

Can't connect to mysql database table?

Oreally

Can't connect to mysql database table?
« on: July 28, 2004, 10:49:23 PM »
Movin' on up the learning curve here....

can't get a php script to connect to a mysql:table as in:

$db = mysql_connect("localhost", "root", "") or  die("could not connect");
mysql_select_db("online",$db);
$result = mysql_query("SELECT AccountID FROM member WHERE fullname =Billy Bob", $db);
$myrow = mysql_fetch_array($result);
$AccountID = $myrow["AccountID"];

I've tried replacing "localhost" with "/path/to/socket", but we still get
"could not connect"

also with and without the password, also with the port number.

Can anyone give me a hint here what I'm doing wrong?

JT

Henk

Can't connect to mysql database table?
« Reply #1 on: July 28, 2004, 11:04:29 PM »
Quote
$db = mysql_connect("localhost", "root", "") or die("could not connect");

You're trying to connect to the mysql database with the user root and no password.


Using MySQL you have to create mysql users. These are different from the user accounts you create in your server-managar!

In SME-Server you better not use the root mysql account, because it has a very long and complicated password. Besides that, it's not very safe to use the root account to access the databases.

You better create a new mysql user with a password, give this user privileges to access the database you want to use.

Easiest to work with mysql is with phpmyadmin. You can find an rpm in the contribs area. Nightspririt made a great working contrib.