I have problem with my newly installed via repo for apache2, mysql, php and phpmyadmin. I was following this tutorial from digitalocean.

For now, my localhost is running and Ubuntu Apache2 default page is appeared. My phpmyadmin is also running and I have import several databases into it.

The issue is, everything in HTML are displayed. But everything that require mysql or mysqli are not functioning. I give two examples here:-

When try run using mysqli:-

$db = new mysqli_connect("localhost","adminmc","123adminmc456","moneychanger");

if($db->connect_errno > 0){
    die('Unable to connect to database [' . $db->connect_error . ']');

The result is still like this:-

Unable to connect to database [Access denied for user 'root'@'localhost' (using password: NO)]

My first trial was using my root username and password. It was still prompt above error. I knew something is not right. I decided to use mysql instead.

When try run using mysql

$c = mysql_connect("localhost", "adminmc", "123adminmc456");
$result = mysql_query("SELECT 'Hello, dear MySQL user!' AS _message FROM DUAL");
$row = mysql_fetch_assoc($result);
echo htmlentities($row['_message']);

Ive got HTTP ERROR 500 instead which mentioned "This page isn’t working".

I honestly not sure what I am doing wrong. I follow the tutorial and even my mysql and phpmyadmin working fine. But I couldn't even connect to database using basic mysqli and mysql php script. Please help me.

1 Answer 1


My apologies. Turn out that I was editing at the old lampp directory which is /opt/lampp/htdocs. I supposed to clear my notepadqq and open based on new directory which is /var/www/html. My bad and my mistake. Everything is fine now. Hopefully anyone encounter this kind of issue please do check your directory of files that you do editing.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.