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 missingh) in yourAppServiceProvider.php'sbootmethod, correcting that toSchema::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
juwelleryjournalyet. You can create it using:- XAMPP's phpMyAdmin: Navigate to
http://localhost/phpmyadmin, click "Databases", enterjuwelleryjournalin the "Create database" field, then click "Create". - MySQL command line: Log into MySQL and run
CREATE DATABASE juwelleryjournal;.
- XAMPP's phpMyAdmin: Navigate to
- Double-check your
.envfile: 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, runphp artisan config:clearto 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
相关产品推荐
相关产品推荐

