Forum Moderators: coopster
I'm a newbie at PHP, and I'm hoping someone could point me in the right direction.
I'm having trouble connecting to MySQL, I'm using the following code:
$link = mysql_connect("localhost", "root") or die (mysql_error());
and getting this error:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in C:\xampp\xampp\htdocs\moviesite\table1.php on line 2
Access denied for user 'root'@'localhost' (using password: NO)
I'm using XAMPP for Windows Version 1.5.5 on a PC with Windows XP service pack 2. Firewall is off. How can I fix my connection?
$link = mysql_connect("localhost", "root", "") or die (mysql_error());
If that dont work, the only other thing i can think of is that MySQL is not turned on in the XAmp control panel?
(but angelis is right, you should set up a user for that particular database with specific privalages)
Ally
[edited by: Scally_Ally at 1:40 pm (utc) on Mar. 20, 2007]
The user was "root" after all, and I specified the password shortly after installation, when I saw that mysql was "UNSECURE". I missed this: "The MySQL admin user root has no longer no password".
I confused MySQL's user settings with the general admin settings, and I thought that since I'd specified a username and a password for XAMPP's general administration, that would apply for MySQL.
So, in the script, I first tried "xamppUsername" and "xampAndMysqlPassword", and then "root" with no password. *shakes head*
And I finally got in phpMyAdmin. What a relief!