I am a novice with Laravel and I'm attempting to establish a connection to my MySQL database. I've created a fresh Laravel installation and when I configure the database values in my .env and database.php files, I consistently encounter an error on the website that displays the following message.
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'practicelaraveldb.sessions' doesn't exist
Then it prompts me to run the migrate command php artisan migrate, and I do, but then I get the error:
Illuminate\Database\QueryException SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (Connection: mysql, SQL: alter table
usersadd uniqueusers_email_unique(at vendor\laravel\framework\src\Illuminate\Database\Connection.php:813 809▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 810▕ ); 811▕ } 812▕ ➜ 813▕ throw new QueryException( 814▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 815▕ ); 816▕ } 817▕ }
I followed the above error's comments and changed the email field in the user's table, and I am still getting errors. Is it really this complicated trying to get a simple database connection? I'm sure I must be missing something here. I followed the directions in the documentation and some YouTube videos.
In the
App\Providers\AppServiceProvider.phpadd the following code.Import Necessary Classes: Ensure that you have imported the necessary classes at the top of the file:
use Illuminate\Support\Facades\Schema;Modify the boot() Method: Add the following line inside the boot() method: