I'm working on a php site that connects to a MySQL database, but when I try run the site I get this error.
Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\htdocs\siteFolder\Connections\conn.php on line 9
Fatal error: Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\htdocs\siteFolder\Connections\conn.php on line 9
I also use Navicat to access the MySQL database and it's also giving me unable to connect error.
Also running XAMPP as a server.
Do you think perhaps its got something to do with XAMPP, because before we were running the sites from a dedicated server and everything use to work great, but we got rid of that and now we using XAMPP as a local server.
Could be. I haven't fiddled with XAMPP for a while (read: since the big forum conversion), but I recall that the default XAMPP installation leaves the MySQL root password blank - could be wrong here though.
Yip the default install does leave root blank. I use one for dev purposes. Careful when changing it though the PHPMyadmin page won't work and you will have to re configure it. That could be your problem. Also MySQL has two ways of storing the password and they are obviously not compatible. I would suggest you have a good read regarding this on MySQL's site.
I'm working on a php site that connects to a MySQL database, but when I try run the site I get this error.
Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\htdocs\siteFolder\Connections\conn.php on line 9
Fatal error: Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\htdocs\siteFolder\Connections\conn.php on line 9
I also use Navicat to access the MySQL database and it's also giving me unable to connect error.
Also running XAMPP as a server.
The error message you are getting normally has to do with MySQL not allowing remote connections or credentials. Also I would HIGHLY recommend that you change the MySQL root user password to NOT be blank as this is a big security risk.
Also try creating a user for that specific database in MySQL and assign it database-specific permissions for the database.
Then use that user in your mysql_connect() function