I am trying to install Laravel. I have installed Xampp, but when I try to setup my database using php artisan migrateI get the error:
[IlluminateDatabaseQueryException] could not find driver (SQL: select * from information_schema.tables where table_schema = homestead
and table_name = migrations) [PDOException] could not find
driver
config/database.php file has the relevant connections:
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
],
],
Any ideas?
$ php artisan migrate:status
+——+————————————————+——-+
| Ran? | Migration | Batch |
+——+————————————————+——-+
| N | 2014_10_12_000000_create_users_table | |
| N | 2014_10_12_100000_create_password_resets_table | |
| N | 2018_04_23_062130_create_categories_table | |
+——+————————————————+——-+
======================================
$ php artisan migrate
IlluminateDatabaseQueryException : SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘users’ already exists (SQL: create table `users` (`id` int unsigned not null auto_increment primary key, `name` varchar(255) not null, `email` varchar(255) not null, `password` varchar(255) not null, `remember_token` varchar(100) null, `created_at` timestamp null, `updated_at` timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci)
at D:OSPaneldomainscatalog.locvendorlaravelframeworksrcIlluminateDatabaseConnection.php:664
660| // If an exception occurs when attempting to run a query, we’ll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database’s errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Exception trace:
1 PDOException::(«SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘users’ already exists»)
D:OSPaneldomainscatalog.locvendorlaravelframeworksrcIlluminateDatabaseConnection.php:458
2 PDOStatement::execute()
D:OSPaneldomainscatalog.locvendorlaravelframeworksrcIlluminateDatabaseConnection.php:458
Please use the argument -v to see more details.
GaneMax@GANEMAX D:OSPaneldomainscatalog.loc
Имя файла миграции для категорий?
2018_04_23_062130_create_categories_table
Создавал файл миграции так
$ php artisan make:migration create_categories_table —create=categories
Running «php artisan migrate» does nothing: no database modifications, no message(olso no «nothing to migrate»), no error.
No records are being added to table migrations as well.
Previously, the command «php artisan migrate» was working fine.
One of the migration files in folder database/migrations has this content:
<?php
use IlluminateDatabaseSchemaBlueprint;
use IlluminateDatabaseMigrationsMigration;
class VidsTableEdit14 extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('vids', function(Blueprint $table)
{
//
$table->integer('test');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('vids', function(Blueprint $table)
{
//
});
}
}
How to make «php artisan migrate» working?
![]()
Aracthor
5,6076 gold badges30 silver badges58 bronze badges
asked May 22, 2015 at 9:51
17
If the migration stops working suddenly there is probably a syntax error somewhere in one of your migrations. If you suddenly get a class not found error be suspicious of a syntax error.
answered Dec 31, 2016 at 0:16
This same happened me, when I was trying to add soft delete to my table.
I created the migration and in the Schema::table function I typed «$table->softDelete();». Instead of
$table->softDeletes();
Notice the ‘s’ for plural, I tried running migration and didn’t get any error or message. I made it plural and it worked.
And I noticed that you didn’t make down function().Try adding:
Schema::drop('vids');
And run the migration again.
answered Jun 4, 2015 at 23:00
1
Error:
SQLSTATE[42S01]
Migrating: 2014_10_12_000000_create_users_table
IlluminateDatabaseQueryException
-------------
[php artisan migrate]
Solution: Go to:
appHttpProvidersAppServiceProvider
import ( use IlluminateSupportFacadesSchema; )
And, inside the register() function, insert this code:
public function register()
{
Schema::defaultStringLength(191);
}
Then run:
php artisan migrate:fresh
Jeremy Caney
6,79353 gold badges48 silver badges74 bronze badges
answered Oct 26, 2020 at 12:30
1
Running «php artisan migrate» does nothing: no database modifications, no message(olso no «nothing to migrate»), no error.
No records are being added to table migrations as well.
Previously, the command «php artisan migrate» was working fine.
One of the migration files in folder database/migrations has this content:
<?php
use IlluminateDatabaseSchemaBlueprint;
use IlluminateDatabaseMigrationsMigration;
class VidsTableEdit14 extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('vids', function(Blueprint $table)
{
//
$table->integer('test');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('vids', function(Blueprint $table)
{
//
});
}
}
How to make «php artisan migrate» working?
![]()
Aracthor
5,6076 gold badges30 silver badges58 bronze badges
asked May 22, 2015 at 9:51
17
If the migration stops working suddenly there is probably a syntax error somewhere in one of your migrations. If you suddenly get a class not found error be suspicious of a syntax error.
answered Dec 31, 2016 at 0:16
This same happened me, when I was trying to add soft delete to my table.
I created the migration and in the Schema::table function I typed «$table->softDelete();». Instead of
$table->softDeletes();
Notice the ‘s’ for plural, I tried running migration and didn’t get any error or message. I made it plural and it worked.
And I noticed that you didn’t make down function().Try adding:
Schema::drop('vids');
And run the migration again.
answered Jun 4, 2015 at 23:00
1
Error:
SQLSTATE[42S01]
Migrating: 2014_10_12_000000_create_users_table
IlluminateDatabaseQueryException
-------------
[php artisan migrate]
Solution: Go to:
appHttpProvidersAppServiceProvider
import ( use IlluminateSupportFacadesSchema; )
And, inside the register() function, insert this code:
public function register()
{
Schema::defaultStringLength(191);
}
Then run:
php artisan migrate:fresh
Jeremy Caney
6,79353 gold badges48 silver badges74 bronze badges
answered Oct 26, 2020 at 12:30
1
|
0 / 0 / 0 Регистрация: 21.07.2017 Сообщений: 8 |
|
|
1 |
|
При выполнении всех миграций выдает ошибку28.10.2017, 19:34. Показов 4291. Ответов 7
Люди подскажите в чем проблема. C:xampphtdocsblog>php artisan migrate [PDOException] Эту проблему решил, добавив кое что в файл: AppServiceProvider.php. И снова ввожу тот же запрос, снова выдается ошибка: C:xampphtdocsblog>php artisan migrate [SymfonyComponentDebugExceptionFatalThrowableEr ror] Кто нибудь знает что делать?(Я новичок)
__________________
0 |
|
183 / 110 / 44 Регистрация: 03.07.2016 Сообщений: 496 |
|
|
28.10.2017, 22:26 |
2 |
|
Первая ошибка говорит вам что в базе данных уже присутствует такая таблица.
0 |
|
0 / 0 / 0 Регистрация: 21.07.2017 Сообщений: 8 |
|
|
29.10.2017, 10:21 [ТС] |
3 |
|
Заново скачал, установил фреймворк, создал новую чистую базу данных, подключился к ней через .env файл(как и нужно) . Ничего в файлах не менял. Выдает те же самые ошибки. C:xampphtdocsblog>php artisan migrate: install [SymfonyComponentConsoleExceptionCommandNotFoun dException] C:xampphtdocsblog>php artisan migrate [IlluminateDatabaseQueryException] [PDOException] После этого в базе появляются две таблицы migrations и users.
0 |
|
4833 / 3848 / 1596 Регистрация: 24.04.2014 Сообщений: 11,292 |
|
|
29.10.2017, 10:25 |
4 |
|
Ruslan111111, значит данная таблица создается в нескольких миграциях
0 |
|
0 / 0 / 0 Регистрация: 21.07.2017 Сообщений: 8 |
|
|
29.10.2017, 11:06 [ТС] |
5 |
|
Врятли.Вот что находится в папке migrations(тут находятся только миграции заданные по умолчанию самим фреймворком): 2014_10_12_000000_create_users_table Добавлено через 12 минут C:xampphtdocsblog3>php artisan make:migration create_articles_table [SymfonyComponentDebugExceptionFatalThrowableEr ror] В папке migrations ничего нового не появляется. Добавлено через 24 минуты C:xampphtdocsblog3>php artisan migrate C:xampphtdocsblog3>php artisan make:migration create_articles_table C:xampphtdocsblog3>php artisan migrate C:xampphtdocsblog3> Таблица новая создалась в базе данных.Как и должна была.
0 |
|
183 / 110 / 44 Регистрация: 03.07.2016 Сообщений: 496 |
|
|
29.10.2017, 17:37 |
6 |
|
users и migrations из базы данных никуда не исчезли А почему они должны исчезнуть?
Parse error: syntax error, unexpected ‘public’ (T_PUBLIC) Ище раз говорю что это вы где то допустили синтаксическую ошибку в скрипте.
0 |
|
0 / 0 / 0 Регистрация: 21.07.2017 Сообщений: 8 |
|
|
03.11.2017, 20:23 [ТС] |
7 |
|
Разобрался вроде. Но почему то все работает лишь при удалении двух стандартных миграций Laravelю
0 |
|
33 / 33 / 28 Регистрация: 04.04.2011 Сообщений: 333 |
|
|
08.05.2018, 14:46 |
8 |
|
У тебя эти 2 миграции не записались в таблицу миграций, потому, что обнаружили уже созданную таблицу users, ее надо было удалить потом снова запустить миграцию. А то, что ты в appServiceProvider что-то поменял, возможно нужно вернуть на место
0 |
