I have setup the ubuntu server and my php code is establishing a database connection with mysql running on the same server. My credentials for the database are correct, crossed checked it thrice but i am unable to figure out what i a missing. So what i have done so far.
Make sure the mysql server is running.
mysql -u root -h 127.0.0.1 -p
// I can login into mysql server on ubuntu server.- Run this command 'netstat -tulpen' and get this entry
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 107 20280 -
Error on apache when php is trying to access mysql:
PHP Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES)
Lastly my database credentials look like this:
// here I have tried 127.0.0.1:3306, localhost as well but it does not seem to work
$dbhost2 = 'localhost:3306';
$dbuser2 = 'root';
$dbpass2 = 'somepassword';
$dbname2 = 'my_db_name';
Updated: This is how i am connecting my php code is using the above variables to connect to the database
$DBCONN2 = @mysqli_connect($dbhost2, $dbuser2, $dbpass2, $dbname2) or die('Failed');
Updated 2: There is also another connection being used like this
$DBCONNi = new mysqli($dbhost2, $dbuser2, $dbpass2, $dbname2) or die('Failed');