Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section General Discussion
  • Search

Issue connecting to MySQL from PHP

General questions about VestaCP
Post Reply
  • Print view
Advanced search
7 posts • Page 1 of 1
Mudloop
Posts: 3
Joined: Thu Sep 30, 2021 3:00 pm

Os: CentOS 6x
Web: apache + nginx
Issue connecting to MySQL from PHP
  • Quote

Post by Mudloop » Thu Sep 30, 2021 3:05 pm

Hi,

I created a database and a user.
Database name is admin_wp (entered wp), username is the same.
Password is xyz (not really :) )

Then I do this :
$db = new mysqli('localhost', 'admin_wp', 'admin_wp', 'xyz');

And I get this error :
Fatal error: Uncaught mysqli_sql_exception: Access denied for user 'admin_wp'@'localhost' (using password: YES) in ...

Am I supposed to use a different user? I can access phpymyadmin with this user, so I don't know what I'm doing wrong.

Thanks!
Top

Mudloop
Posts: 3
Joined: Thu Sep 30, 2021 3:00 pm

Os: CentOS 6x
Web: apache + nginx
Re: Issue connecting to MySQL from PHP
  • Quote

Post by Mudloop » Thu Sep 30, 2021 3:09 pm

Also, I tried this :
mysql -u admin_wp -p

And that worked. So no idea why it's not working from my simple PHP script.
Top

Mudloop
Posts: 3
Joined: Thu Sep 30, 2021 3:00 pm

Os: CentOS 6x
Web: apache + nginx
Re: Issue connecting to MySQL from PHP
  • Quote

Post by Mudloop » Thu Sep 30, 2021 3:29 pm

Tried making a new user :

Code: Select all

grant all on admin_wp.* to 'web'@'%' identified by 'c3cg5yTqXNsJzcq9';
(don't worry, it's a temp password)

Code: Select all

+---------------+-----------+
| user          | host      |
+---------------+-----------+
| admin_default | %         |
| admin_wp      | %         |
| web           | %         |
| web           | 127.0.0.1 |
| admin_default | localhost |
| admin_wp      | localhost |
| phpmyadmin    | localhost |
| root          | localhost |
| roundcube     | localhost |
| web           | localhost |
+---------------+-----------+
(note, made it a couple of times with different host but same password)

Code: Select all

$db = new mysqli('127.0.0.1', 'web', 'admin_wp', 'c3cg5yTqXNsJzcq9');
Result :
Fatal error: Uncaught mysqli_sql_exception: Access denied for user 'web'@'localhost' (using password: YES)
Top

grayfolk
Support team
Posts: 1111
Joined: Tue Jul 30, 2013 10:18 pm
Contact:
Contact grayfolk
Website Facebook Skype Twitter

Os: CentOS 6x
Web: nginx + php-fpm
Re: Issue connecting to MySQL from PHP
  • Quote

Post by grayfolk » Thu Sep 30, 2021 5:40 pm

Mudloop wrote: ↑
Thu Sep 30, 2021 3:29 pm

Result :
Fatal error: Uncaught mysqli_sql_exception: Access denied for user 'web'@'localhost' (using password: YES)
Due to official documentation looks like youre wrong with arguments order.
Top

nbaever3
Posts: 1
Joined: Sun Oct 24, 2021 10:49 am

Os: Debian 9x
Web: nginx + php-fpm
Re: Issue connecting to MySQL from PHP
  • Quote

Post by nbaever3 » Fri Oct 29, 2021 7:14 am

i got same problem
Top

grayfolk
Support team
Posts: 1111
Joined: Tue Jul 30, 2013 10:18 pm
Contact:
Contact grayfolk
Website Facebook Skype Twitter

Os: CentOS 6x
Web: nginx + php-fpm
Re: Issue connecting to MySQL from PHP
  • Quote

Post by grayfolk » Fri Oct 29, 2021 7:58 am

nbaever3 wrote: ↑
Fri Oct 29, 2021 7:14 am
i got same problem
Check your database credentials, check arguments order.
Top

clementishutin
Posts: 24
Joined: Thu Dec 30, 2021 10:04 am

Os: CentOS 7x
Web: apache
Re: Issue connecting to MySQL from PHP
  • Quote

Post by clementishutin » Wed Jan 19, 2022 6:12 am

Did the issue resolved after looking into database?
Top


Post Reply
  • Print view

7 posts • Page 1 of 1

Return to “General Discussion”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

cron

Login  •  Register

I forgot my password