Framework: PHP artisan migration

Created on 6 Oct 2019  路  5Comments  路  Source: laravel/framework

I found this error, how to fix and suggest me. thanks

waiphyo@acer:/var/www/html/comeback$ php artisan migrate

Illuminate\Database\QueryException : SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost' (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')

at /var/www/html/comeback/vendor/laravel/framework/src/Illuminate/Database/Connection.php:665
661| // If an exception occurs when attempting to run a query, we'll format the error
662| // message to include the bindings with SQL, which will make this exception a
663| // lot more helpful to the developer instead of just the database's errors.
664| catch (Exception $e) {

665| throw new QueryException(
666| $query, $this->prepareBindings($bindings), $e
667| );
668| }
669|

Exception trace:

1 PDOException::("SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'")
/var/www/html/comeback/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=laravel", "root", "", [])
/var/www/html/comeback/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

Please use the argument -v to see more details.

Most helpful comment

Nothing to do with .env file, it's a mysql issue, besides this line

PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=laravel", "root", "", [])

Shows what userid and password he is using. Try this

sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';

All 5 comments

i guess u need to give a super user permission.

# Try this command

$ sudo php artisan migrate

If it's not working, did you set a password in MySQL?
If you set it, did you change set yojr database password in ".env" file?

./.env

...
DB_USER=your_username
DB_PASS=your_password
...

Nothing to do with .env file, it's a mysql issue, besides this line

PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=laravel", "root", "", [])

Shows what userid and password he is using. Try this

sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';

There is no need to run artisan commands from sudo. Ever.

Hi there,

Welcome to Laravel and we are glad to have you as part of the community.

Unfortunately this GitHub area is not a support area for general application issues. This is only for issues/bugs with the framework code itself.

I will be closing your ticket here. Instead please try asking your question on one of the many great community support areas that will likely give you a better answer more quickly:

  • Laravel Slack (https://larachat.co/)
  • Laravel.io Forum (https://laravel.io/forum)
  • Laracasts Forum (https://laracasts.com/discuss)
  • StackOverflow (http://stackoverflow.com/questions/tagged/laravel)

If you feel I've closed this issue in error, please provide more information about how this is a framework issue, and I'll reopen the ticket.

Thanks in advance.

Thanks all for your suggestions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Anahkiasen picture Anahkiasen  路  3Comments

lzp819739483 picture lzp819739483  路  3Comments

gabriellimo picture gabriellimo  路  3Comments

YannPl picture YannPl  路  3Comments

iivanov2 picture iivanov2  路  3Comments