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

  • Home
  • SEARCH
  • 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 7760037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:46:40+00:00 2026-06-01T13:46:40+00:00

I am just setting up a new VPS learning to setup my own web

  • 0

I am just setting up a new VPS learning to setup my own web server and stuck at this pretty basic step.

PHP 5.3.3
MySQL 5.1.61
CentOS release 6.2 (Final)

I can connect to the server using mysql at the command line or remotely using Navicat without issues. I’ve put the host as ‘%’ for testing as localhost wouldn’t work either. I have tried with “localhost”, IP, etc.

Connect failed: Access denied for user 'stats'@'localhost' (using password: YES)

Users:

+-----------+---------+
| Host      | User    |
+-----------+---------+
| %         | stats   |
| 127.0.0.1 | root    |
| localhost | root    |
+-----------+---------+

My code:

<?php
    $mysqli = new mysqli("localhost", "user", "db", "pw");
?>

Error when running the php script directly from the command line (No web server):

PHP Warning:  mysqli::mysqli(): (28000/1045): Access denied for user 'stats'@'localhost' (using password: YES) in /xxx/db.php on line 5
Connect failed: Access denied for user 'stats'@'localhost' (using password: YES)

The same is returned when running through apache.

Thanks in advance.

  • 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-06-01T13:46:42+00:00Added an answer on June 1, 2026 at 1:46 pm

    This line:

    $mysqli = new mysqli("localhost", "user", "db", "pw");
    

    Should be:

    $mysqli = new mysqli("localhost", "user", "pw", "db");
    

    password comes before database name

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

Sidebar

Related Questions

Just a small SVN problem here. I setup my own SVN server Setting up
I just moved my website to a new server (Shared to VPS) I expected
I have a DIV containing text. Previously I just tried setting new HTML like
I've just been setting up a new 10 netbook and have just installed Eclipse
I'm new to the mac world and have just been setting up my webserver.
we are setting up new QE testing server. I guess host OS will be
I have just done the website migration from the old server to the new
I'm just setting up the live environment for my new project. Unlike my dev
I am just setting up a simple library application, basically a collection of Members
I am working in flex and I am just setting a variable to false.

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.