I have the following error upon doing: php artisan migrate

  Thu 11 / 05 / 2023

  Posted by: Moza AlKaabi

Category : Php

Tags : laravel , php , php laravel , web , backend , deployment

Post Thumbnail
Description

    Illuminate\Database\QueryException 

  SQLSTATE[HY000]: General error: 1449 The user specified as a definer ('mysql.infoschema'@'localhost') does not exist (Connection: mysql, SQL: select * from information_schema.tables where table_schema = cms and table_name = migrations and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:760
    756▕         // If an exception occurs when attempting to run a query, we'll format the error
    757▕         // message to include the bindings with SQL, which will make this exception a
    758▕         // lot more helpful to the developer instead of just the database's errors.
    759▕         catch (Exception $e) {
  ➜ 760▕             throw new QueryException(
    761▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    762▕             );
    763▕         }
    764▕     }

      +28 vendor frames 

  29  artisan:35
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))


View Code
                        Illuminate\Database\QueryException 

  SQLSTATE[HY000]: General error: 1449 The user specified as a definer ('mysql.infoschema'@'localhost') does not exist (Connection: mysql, SQL: select * from information_schema.tables where table_schema = cms and table_name = migrations and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:760
    756▕         // If an exception occurs when attempting to run a query, we'll format the error
    757▕         // message to include the bindings with SQL, which will make this exception a
    758▕         // lot more helpful to the developer instead of just the database's errors.
    759▕         catch (Exception $e) {
  ➜ 760▕             throw new QueryException(
    761▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    762▕             );
    763▕         }
    764▕     }

      +28 vendor frames 

  29  artisan:35
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
                
  Answered by CDL

Delete the problematic user using the below command

~~~

DROP USER 'mysql.infoschema'@'localhost';

~~~

The rest of the solution is like the previous answers.

Create the user again

Grant it permissions

~~~

mysql> CREATE USER 'mysql.infoschema'@'localhost' IDENTIFIED BY 'password';

mysql> GRANT SELECT ON *.* TO `mysql.infoschema`@`localhost`;

~~~

  Comment   Share
0 Likes   0 Comments