'Can't using php artisan migrate
I create new project laravel and I want to migrate, so I do
php artisan serve
but why I got
SQLSTATE[HY000] [1049] Unknown database 'laravel' (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')
I do following this advise
to change the value in DB_HOST, but when I checked, it was completely just set like that advice
my .env
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:TqD4fedTyWRixmGVCzmjFHSriROFu/57yZRZeM5YI6Q=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
I also do
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan view:clear
I do change in file database.php from
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
to
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
instead of done, it give me
SQLSTATE[42S01]: Base table or view already exists: 1050 Table
'users' already exists (SQL: create table `users` (`id` bigint
unsigned not null auto_increment primary key, `name`
varchar(255) not null, `email` varchar(255) not null,
`email_verified_at` timestamp null, `password` varchar(255) not
null, `remember_token` varchar(100) null, `created_at` timestamp
null, `updated_at` timestamp null) default character set utf8
collate 'utf8_unicode_ci')
when I wrote again, it still got the same way
before this, I wrote migrate and still good, why it's get hard than before?
thank's
Solution 1:[1]
When you use php artisan migrate laravel runs up the migrations without drop the tables thats why your SQL engine returns that users table already exists, if you are working on a fresh project try using php artisan migrate:fresh
here the docs
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Julio Guerrero |
