简体   繁体   English

SQLSTATE[HY000]:一般错误:1030 运行迁移时出现错误 168

[英]SQLSTATE[HY000]: General error: 1030 Got error 168 when running migrations

I have a fresh installation of laravel 7 which I installed through composer, created the database and connected in the .env.我有一个全新安装的 laravel 7,我通过 composer 安装了它,创建了数据库并在 .env 中连接。 However, when I run migrations, I see the following error:但是,当我运行迁移时,我看到以下错误:

    ➜  laravel-adp-4 git:(develop) ✗ php artisan migrate

   Illuminate\Database\QueryException

  SQLSTATE[HY000]: General error: 1030 Got error 168 - 'Unknown (generic) error from engine' from storage engine (SQL: create table `migrations` (`id` int unsigned not null auto_increment primary key, `migration` varchar(255) not null, `batch` int not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')

I can confirm that all my services are up:我可以确认我的所有服务都已启动:

➜  laravel-adp-4 git:(develop) ✗ brew services list
Name      Status  User    Plist
mysql     started macbook /Users/macbook/Library/LaunchAgents/homebrew.mxcl.mysql.plist
mysql@5.7 started macbook /Users/macbook/Library/LaunchAgents/homebrew.mxcl.mysql@5.7.plist
nginx     started root    /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
php       started root    /Library/LaunchDaemons/homebrew.mxcl.php.plist
php@7.3   started macbook /Users/macbook/Library/LaunchAgents/homebrew.mxcl.php@7.3.plist

Trying to troubleshooting I noticed that I can no longer manipulate mysql.尝试进行故障排除时,我注意到我无法再操作 mysql。 When I try to create another database, I see the following error:当我尝试创建另一个数据库时,我看到以下错误:

ERROR 3680 (HY000): Failed to create schema directory 'alala' (errno: 2 - No such file or directory)

Why am I not able to run migrations?为什么我无法运行迁移? Why am I not able to create a database?为什么我无法创建数据库?

Your query is nt ok you have a single quote too much around utf8mb4_unicode_ci您的查询不正确,您在utf8mb4_unicode_ci周围有太多单引号

create table `migrations` (`id` int unsigned not null auto_increment primary key, `migration` varchar(255) not null, `batch` int not null) 
default character set utf8mb4 collate utf8mb4_unicode_ci

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM