We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on Vesta 2.0 and expect to release it by the end of 2024. Read more about it: https://vestacp.com/docs/vesta-2-development
Issue connecting to MySQL from PHP
Issue connecting to MySQL from PHP
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!
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!
Re: Issue connecting to MySQL from PHP
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.
mysql -u admin_wp -p
And that worked. So no idea why it's not working from my simple PHP script.
Re: Issue connecting to MySQL from PHP
Tried making a new user :
(don't worry, it's a temp password)
(note, made it a couple of times with different host but same password)
Result :
Fatal error: Uncaught mysqli_sql_exception: Access denied for user 'web'@'localhost' (using password: YES)
Code: Select all
grant all on admin_wp.* to 'web'@'%' identified by 'c3cg5yTqXNsJzcq9';
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 |
+---------------+-----------+
Code: Select all
$db = new mysqli('127.0.0.1', 'web', 'admin_wp', 'c3cg5yTqXNsJzcq9');
Fatal error: Uncaught mysqli_sql_exception: Access denied for user 'web'@'localhost' (using password: YES)
-
- Support team
- Posts: 1111
- Joined: Tue Jul 30, 2013 10:18 pm
- Contact:
- Os: CentOS 6x
- Web: nginx + php-fpm
Re: Issue connecting to MySQL from PHP
Due to official documentation looks like youre wrong with arguments order.
Re: Issue connecting to MySQL from PHP
i got same problem
-
- Posts: 24
- Joined: Thu Dec 30, 2021 10:04 am
- Os: CentOS 7x
- Web: apache
Re: Issue connecting to MySQL from PHP
Did the issue resolved after looking into database?