0

I tried to migrate from mysql localhost database to mysql azure database in Laravel. So, I changed the environment variables (.env) as this:

DB_CONNECTION=mysql
DB_HOST=database.mysql.database.azure.com
DB_PORT=3306
DB_DATABASE=myquery_use
DB_USERNAME=database
DB_PASSWORD=password

However, when I tried to migrate a table into the system, the error like above appear. What should I fix so the laravel and mysql azure are connected?

  PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1142 CREATE command denied to user 'database'@'121' for table 'migrations'")
          C:\xampp\htdocs\system\vendor\laravel\framework\src\Illuminate\Database\Connection.php:452  
swm
  • 519
  • 1
  • 4
  • 20

1 Answers1

2

You need to grant privileges for the user before it can create the table. Not all MySql users will have permission to do this but the root user should do.

 GRANT ALL PRIVILEGES ON `myquery_use`.* TO 'database'@'localhost'

You may also need to run FLUSH PRIVILEGES after for changes effect.

Tom
  • 128
  • 1
  • 6