[Doctrine\DBAL\Driver\PDOException] could not find driver
这是执行
php artisan migrate
后报的错!
一种是 没有配置 数据库的链接方式!
在config/database.php 里有多种链接方式!
可以在 .env 里设置你需要链接的数据库驱动
默认是mysql
如果这里设置没有问题!
看看你环境mysql是否开启或者是否安装!!!!
我的本地安装过了!
但是我用 mysql 提示我要安装!
The program 'mysql' can be found in the following packages:
* mysql-client-core-5.7
* mariadb-client-core-10.0
Try: apt install <selected package>
我明明已经安装!
那么,就是mysql没有设置环境变量!
vim /etc/profile
跳到最后一行!
加上
export PATH=/usr/local/nginx/sbin:/usr/local/php/bin:/usr/local/mysql/bin:$PATH
上面是加了nginx,php,mysql三者的!看着改!
然后保存后
source /etc/profile
在回去执行mysql 就有了!
本站(PHP --> Golang)已重构,代码开源
当你能力不能满足你的野心的时候,你就该沉下心来学习
当你能力不能满足你的野心的时候,你就该沉下心来学习
General error: 1215 Cannot add foreign key constraint (SQL: alter table
iphpt_categoriesadd constraint iphpt_categories_art_id_foreign foreign key (art_id) referencesarticle(id) on delete cascade on update cascade)
Schema::create('iphpt_categories', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->integer('art_id')->unsigned();
$table->integer('cate_id')->unsigned();
$table->foreign('art_id')->references('id')->on('iphpt_article');
$table->foreign('cate_id')->references('id')->on('iphpt_category');
$table->primary(['art_id', 'cate_id']);
});
建立文章标签与文章对应的表时报错 然后把 > $table->integer(‘art_id’)->unsigned(); > $table->integer(‘cate_id’)->unsigned();
里面加上10 > $table->integer(‘art_id’)->unsigned(10); > $table->integer(‘cate_id’)->unsigned(10);
然后就可以了!
运行这个语句前,iphpt_article 和 iphpt_category两个表必须存在,否则还会报错
> SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table iphpt_tags add constraint iphpt_tags_tag_id_foreign foreign key (tag_id) references iphpt_tag (id))
本站(PHP --> Golang)已重构,代码开源
当你能力不能满足你的野心的时候,你就该沉下心来学习