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 6965853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:06:55+00:00 2026-05-27T16:06:55+00:00

I connected to MySQL from PHP using root user. Connection object was $con .

  • 0

I connected to MySQL from PHP using root user. Connection object was $con. The connection was successful.

I wanted to select a particular database so I used mysql_select_db('database', $con), but I got an 'Access denied for user '@'localhost' to database' error.

I can’t understand why I got an access denied error, as I am using root user. I double-checked the grants for root and it has all privileges on .. And I am able to execute queries on this particular database through the command line client using root. I am running everything on my local machine.

  • 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-27T16:06:55+00:00Added an answer on May 27, 2026 at 4:06 pm

    You’re not using the root account (which is a BAD idea regardless of what you’re trying to do). The error message clearly states ... for user ''@localhost: there’s no username in there, so you’ve connected with no username at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<?php $con= mysql_connect(localhost,root,mysql); mysql_select_db(Db_name,$con); $res=mysql_query(select *from table_name); mysql_close($con); // closing connection before fetching contents.
I am using nginx, PHP and MYSQL. I setup a database and a user
I'm trying to connect to remote MySQL server with SSL from PHP using mysql_connect:
I am trying to get Ajaz to pull data from mysql using a php
I have a problem with retrieving data from a database using PHP statements. At
I got this code from this site: http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/using-php-to-backup-mysql-databases.aspx But I'm just a beginner so
<?php $dbserver=localhost; $username=root; $pass=root; $link=mysql_connect($dbserver,$username,$pass); if(!$link){die('DB Connection Failed'.mysql_error()); } echo('connected'); $Name=$_POST[namei]; $ID=$_POST[pid]; $Address=$_POST[address]; $Phone=$_POST[phone];
This is my php script for fetching data from a db. <?php mysql_connect(host,user,pass); mysql_select_db(db);
Im trying to connect MySql from VB.NET in visual basic 2010. I wanted to
How can I connect to a MySQL database from Windows Forms?

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.