Welcome Guest, Not a member yet? Register   Sign In
Cant connect to db [SOLVED]
#1

(This post was last modified: 10-07-2024, 09:30 PM by InsiteFX.)

I have this error:
Access denied for user '*****'@localhost (using password: YES)
But its a weird issue.

If I connect throught model the connection works with no problem. By example if I do
$orders = (new OrdersModel)->findAll();
works OK
but If I try
$db = \Config\Database::connect();
$query = $db->query("SELECT * FROM view_orders ORDER BY id DESC");
$orders = $query->getResult();

then I got this message:

ERROR - 2024-10-06 16:21:12 --> Access denied for user '****'@localhost (using password: YES)

CRITICAL - 2024-10-06 16:21:12 --> Call to a member function getResult() on bool
Any ideas?

Nevermind.
It was a migration issue.
It was trying to connect to a view of db and the view has a different user.
Maybe it helps to someone else.
What I did when I imported db is change this:
CREATE ALGORITHM=UNDEFINED DEFINER=`******`@localhost SQL SECURITY DEFINER VIEW `view_orders`  AS
to this:
CREATE VIEW `view_orders`  AS
and problem solved
Reply




Theme © iAndrew 2016 - Forum software by © MyBB