PHP connection - Lumen

Asked

Viewed 75 times

1

I am learning PHP with Lumen and came across a problem in the api connection string.

I have mysql installed and can use it normally via Workbench. When I click to see the connection information, an information appears that the Host name is INT-WKS10. However, when I turn the command down:

select user,host from mysql.user

I get the result:

sa                  %
mysql.infoschema    localhost

mysql.session       localhost

mysql.sys           localhost

root                localhost

I have tried several settings. When I set up DB_HOST with localhost, I get the following error:

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL:

When I use the INT-WKS10, I get the error:

SQLSTATE[HY000] [1045] Access denied for user 'root'@'INT-WKS10.integro.inf.br' (using password: YES)

Below my connection

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=agendamento
DB_USERNAME=root
DB_PASSWORD=123456
  • I believe your problem is to create a user with all the privileges in the bank, instead of using root.

  • I did it and it didn’t work. Does it have to do with the type of authentication? The options are standard, SHA256 Password or caching_sha2_password.

  • The root user only has access via localhost, and you are apparently trying to access from another computer. You need to create a user who has permission like the user sa there, who has permission %-> any source

  • I’m accessing the base on my local machine

  • But the bank is in your local machine?

  • Got it! Thanks! I created a user similar to sa and put the standard connection type.

  • And yes. DB is local

  • I’ll write the answer, mark it as answered, okay? You did what I said, or what Rafael Mena said?

  • INT-WKS10.integro.inf.br is a hosting? If yes, you should have a dashboard and in that dashboard for mysql within the hosting it creates a user and password for you, which nay is the "root" ... If it is another pc on your network, then you have to talk to who installed mysql to see which user is used. PS: for most things "root" is an exaggeration, in common and even advanced applications we usually do not need "root" access, root is something only interesting to those who maintain in the general bank and have permission for it.

Show 4 more comments

1 answer

-1

I believe your problem is to create a user with all the privileges in the bank, instead of using root.

As much as your connection is local, your application requires the user to be default (root).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.