简体   繁体   中英

Access denied for user 'root'@'localhost' (using password: NO) in Joomla when using another user account

I'm working on a hosting which currently have Joomla installed. I want to test my new page which doesn't run over Joomla, neither Wordpress, neither any other CMS, It is just php code from scratch.

I created a new folder on the hosting but when I try to access via:

myhosting.com/mynewfolder/index.php

I get the next error

Access denied for user 'root@localhost' (using password:NO)

...but, the problem is that I'm not using root user. I'm trying to connect to another database which is in another server with a different username, not "root". I'm trying to connect using the next code, which works perfectly in my localhost:

$conn =  mysql_connect('external-hosting-on-another-server.com', 'username-not-root', 'password');

I'm pretty sure that hosting accepts external connections because, as I said, It works on my localhost.

I don't understand why it is trying to connect using a "root" user. I think it has something to do with Joomla, but I'm not sure.

Maybe if I delete all Joomla files in the hosting and upload only my files it will work, do you think?

Thank you for your help.

Does user have privileges of this database? You must to give it privileges about this database. From your database.

Try it, I believe that is this. Here I put the sentence that I use:

$con = mysql_connect("host","user","pass") or die ("Could not connect to database");

var_dump($con);

If var_dump($con) return resulset, is connected to database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM