Author Topic: Access denied for user ''@'localhost' (using password: NO)  (Read 1321 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
Access denied for user ''@'localhost' (using password: NO)
« on: November 27, 2017, 04:30:08 AM »
Hi guys,

OK. before i get started, i need to inform you the following.. i am using php 5.3 as it is the only php i know, :)..

so i have installed everything, the cwp on centos, as explained in the installation, have set up the whole server with no problems, set up the website with no problems, but having major problems with the mysql connection.

Code: [Select]
$link = mysql_connect("localhost", "user", "password")
  or die("Unable to connect to MySQL" . mysql_error());
 
$db_selected = mysql_select_db("table", $link);
if (!$db_selected) {
   die ('Can\'t use table: ' . mysql_error());

I get no errors from the above connection attempt, but as soon as i try to run a query i get the main error

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

now i can see that for some reason the user details, and password are not being recieved or processed in the DB.

i have rebooted everything, changed passwords, (i cannot access on either root password, or my account password or an additional mysql account set up )

any idea what the problem is..

This has been set up on an internal network. the system does have access to the internet, but is mainly for internal use only..

any help would be appreciated..
« Last Edit: November 27, 2017, 04:35:39 AM by krappleby »

Offline
***
Re: Access denied for user ''@'localhost' (using password: NO)
« Reply #1 on: November 27, 2017, 09:35:32 PM »
Did you try 127.0.0.1 instead of localhost in your PHP code?
https://www.24x7servermanagement.com/
Server Management, Server Security, Server Monitoring.
India's Leading Managed Service Provider !!