Laravel SQLSTATE[HY000] [1049] Unknown database 'previous_db_name'

Asked
Active3 hr before
Viewed126 times

5 Answers

laravel
90%

Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers ,From what it seems the database.php file is not where the variable is from., This helped me! Coming from Ruby on Rails, I was expecting a command similar to rails db:create and just realised there isn't such thing in Laravel. – DJenuil May 31 at 10:41 ,I know, it is super late but for people like me, new in laravel and following tutorial from artisansweb. Note that, migrate will not create your database. Rather, it will just create all the tables. Assuming, you have set up your .env file. Now the important part is create the database and users (if you decided to go with custom users) manually. Then, do the php artisan migrate command

Please run this command:

php artisan config: cache
load more v
88%

I have this error when i use php artisan migrate in my Laravel project.,It clearly mentions that there's no such database named previous_db_name.,I had to kill my server and re-run php artisan serve for my project to register the change of my DB_DATABASE name. I kept getting the error even after clearing the cache because I didn't realize this.,.env file in the project folder

I have this error when i use php artisan migrate in my Laravel project.

[PDOException]
SQLSTATE[HY000][1049] Unknown database 'previous_db_name'

this is my database.php file :

'default' => env('DB_CONNECTION', 'mysql'),
   'connections' => [

      'mysql' => [
         'driver' => 'mysql',
         'host' => env('DB_HOST', 'localhost'),
         'database' => env('DB_DATABASE', 'current_db_name'),
         'username' => env('DB_USERNAME', 'root'),
         'password' => env('DB_PASSWORD', ''),
         'charset' => 'utf8',
         'collation' => 'utf8_unicode_ci',
         'prefix' => '',
         'strict' => false,
      ],
   ],
load more v
72%

I have this error when i use php artisan migrate in my Laravel project.,Laravel SQLSTATE[HY000] [1049] Unknown database 'previous_db_name' ,It clearly mentions that there's no such database named previous_db_name.,From what it seems the database.php file is not where the variable is from.

I have this error when i use php artisan migrate in my Laravel project.

[PDOException]
SQLSTATE[HY000][1049] Unknown database 'previous_db_name'
load more v
65%

Laravelプロジェクトでphp artisan merge を使用すると、このエラーが発生します。,DB_DATABASE名の変更を登録するには、サーバーを強制終了し、プロジェクトでphp artisanserve を再実行する必要がありました。これに気づかなかったため、キャッシュをクリアした後もエラーが発生し続けました。,previous_db_name という名前のデータベースがないことを明確に示しています。,php artisan cache:clear

Laravelプロジェクトでphp artisan merge を使用すると、このエラーが発生します。

[PDOException]
SQLSTATE[HY000][1049] Unknown database 'previous_db_name'
'default' => env('DB_CONNECTION', 'mysql'),
   'connections' => [
      'mysql' => [
         'driver' => 'mysql',
         'host' => env('DB_HOST', 'localhost'),
         'database' => env('DB_DATABASE', 'current_db_name'),
         'username' => env('DB_USERNAME', 'root'),
         'password' => env('DB_PASSWORD', ''),
         'charset' => 'utf8',
         'collation' => 'utf8_unicode_ci',
         'prefix' => '',
         'strict' => false,
      ],
   ],

これを試してください:

< ? php
class Config {
   private $host = "localhost";
   private $db_name = "db_ahp";
   private $username = "root";
   private $password = "";
   public $conn;
   public
   function getConnection() {
      $this - > conn = null;
      try {
         $this - > conn = new PDO("mysql:host=".$this - > host.
            ";dbname=".$this - > db_name, $this - > username, $this - > password);
      } catch (PDOException $exception) {
         echo "Connection error: ".$exception - > getMessage();
      }
      return $this - > conn;
   }
}

次のコマンドを実行してください:

php artisan config: cache
load more v
75%

У меня есть эта ошибка, когда я использую php artisan migrate в своем проекте Laravel. [PDOException] SQLSTATE[HY000] [1049] Unknown database 'previous_db_name' это мой файл database.php : 'default'... , Laravel SQLSTATE[HY000] [1049] неизвестная база данных 'previous_db_name' , Laravel PDOException SQLSTATE[HY000] [1049] неизвестная база данных 'forge' , У меня есть эта ошибка, когда я использую php artisan migrate в своем проекте Laravel. [PDOException] SQLSTATE[HY000] [1049] Unknown database 'previous_db_name' это мой файл database.php : 'default' => env('DB_CONNECTION', 'mysql'), 'connections' => [ 'mysql' => [ 'driver' => 'mysql',...

Я хочу получить доступ к данным Mysql первым шагом является создание новой таблицы для "vanvlymen", и я набрал mysql> USE vanvlymen; база данных изменилась. и введите SHOW таблиц; показывая доступные таблицы, которые содержит база данных.

mysql - u root - p
enter password: ** **

   mysql > show databases; -
databases -

   information_schema
mysql
performance_schema
phpmyadmin
vanvlymen

5 rows...

app/config/database.php

   'mysql' => array(
      'driver' => 'mysql',
      'host' => 'localhost',
      'database' => 'vanvlymen',
      'username' => 'foobar',
      'password' => 'foobar',
      'charset' => 'utf8',
      'collation' => 'utf8_unicode_ci',
      'prefix' => '',
   ),

Я пытался очистить кэш таким образом

 php artisan cache: clear

 php artisan migrate

это ошибки:

 SQLSTATE[42000][1049] unknown database 'forge'.
load more v