Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7174847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:08:53+00:00 2026-05-28T16:08:53+00:00

[Updated below] I am having a problem connecting to a MySQL database using a

  • 0

[Updated below]

I am having a problem connecting to a MySQL database using a Bitnami LAMP stack. This is the code I used to connect on the shared-hosting server where I originally hosted the database:

DEFINE ('DB_USER', 'username');
DEFINE ('DB_PASSWORD', 'password');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'database');

if ($dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)) { // Make the connnection.

    if (!mysql_select_db (DB_NAME)) { // If it can't select the database.

        // Handle the error.
        trigger_error("Could not select the database!\n<br />MySQL Error: " . mysql_error());

        exit();

    } // End of mysql_select_db IF.

} else { // If it couldn't connect to MySQL.

    trigger_error("Could not connect to MySQL!\n<br />MySQL Error: " . mysql_error());
    exit();

} // End of $dbc IF.

Running this on my Bitnami server, I get no response (not even an error message). (PHP is working fine.)

I then tried

<?php
$link = mysql_connect('localhost', 'username', 'password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

and got

Could not connect: Access denied for user 'username'@'localhost' (using password: YES)

this username/password combination definitely exists and (as far as I can tell) has access to the database in question. I am wondering what I am doing wrong and why the original script does not produce an error (or connect).

Update:

I followed Michael’s suggestion below, and was able to connect. I wanted to reproduce the issue so I deleted that user then created a user testuser via

CREATE USER 'testuser'@'%' IDENTIFIED BY  '***';

GRANT SELECT , 
INSERT ,

UPDATE ,
DELETE ,
FILE ON * . * TO  'testuser'@'%' IDENTIFIED BY  '***' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;

Then following Michael’s suggestion, I executed

GRANT ALL PRIVILEGES ON test . * TO testuser@localhost IDENTIFIED BY  'password'

but again I am getting

Could not connect: Access denied for user 'testuser'@'localhost' (using password: YES)

(This doesn’t work whether I use ‘%’ or ‘localhost’)

this is what the privileges look like for testuser in phpmyadmin

Database    Privileges  Grant   Table-specific privileges
test     ALL PRIVILEGES No  No   Edit Privileges
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:08:55+00:00Added an answer on May 28, 2026 at 4:08 pm

    The error message received is clear – the user you’re connecting with does not have access via the password you are using. You’ll need to grant privileges accordingly:

    GRANT ALL PRIVILEGES on dbname.* to username@localhost IDENTIFIED BY 'thepassword';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem when trying to execute this update statement (below) using C#
I am having problem in clearing the cache in asp.net. Below is my code
ORIGINAL (see UPDATED QUESTION below) I am designing a new laboratory database that tests
I am using the below code to update my progress bar. ProgressBar.Visible = true;
The code below models a simple SIR model (used in disease control) in Mathematica.
im having some problems... code is below: delegate void SetCanvasDelegate(PictureBox canvas); public void SetCanvas(PictureBox
I was having problems updating information in my SQL database using my vb.net application,
I am having a problem that I cannot figure out. I am using the
UPDATED See post #3 below. There is a need to upload a file to
Updated question, see below I'm starting a new project and I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.