You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel 5.5.28出现方法未定义及数据库不存在错误求解决方案

Solutions to Your Laravel 5.5.28 Issues

Let's break down your two problems and walk through practical fixes for each one:

1. Fixing "call to undefined method MySqlBuilder::defaultStringLenght()" Error

First off, I spotted a tiny but critical spelling mistake in the error message—defaultStringLenght is missing an h (it should be defaultStringLength). That's a super easy typo to overlook, so let's start there:

  • Check your code for typos: If you added Schema::defaultStringLenght() (with the missing h) in your AppServiceProvider.php's boot method, correcting that to Schema::defaultStringLength(191) will likely resolve the issue immediately.
  • Verify Schema Facade import: Make sure you have the correct use statement at the top of AppServiceProvider.php:
    use Illuminate\Support\Facades\Schema;
    
  • Clear Laravel caches: Sometimes outdated cached classes or configs can trigger weird "method not found" errors. Run these commands in your project root:
    php artisan config:clear
    php artisan clear-compiled
    

2. Fixing "Unknown database 'juwelleryjournal'" During Migrations

The php artisan make: commands don't require a database connection to run, which is why those work smoothly—migrations, however, need to connect directly to your MySQL instance. Here's what to check:

  • Create the database manually: The error confirms MySQL doesn't have a database named juwelleryjournal yet. You can create it using:
    • XAMPP's phpMyAdmin: Navigate to http://localhost/phpmyadmin, click "Databases", enter juwelleryjournal in the "Create database" field, then click "Create".
    • MySQL command line: Log into MySQL and run CREATE DATABASE juwelleryjournal;.
  • Double-check your .env file: Confirm these values match your actual MySQL setup:
    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=juwelleryjournal
    DB_USERNAME=root # or your custom MySQL username
    DB_PASSWORD= # XAMPP defaults to empty; use your password if you set one
    
  • Clear config cache: After updating .env, run php artisan config:clear to ensure Laravel uses the new settings instead of cached old configurations.

If you try these steps and still hit snags, feel free to share more details about your AppServiceProvider code or MySQL setup!

内容的提问来源于stack exchange,提问作者Jurgis Florijonas Vaiginis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:07:47