Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mirzaabdulahizhar's avatar

PDOException::("SQLSTATE[HY000] [1049] Unknown database

Having this error for the past 2 days. Whenever I run "php artisan migrate" command. I've tried the following solutions:-

  1. php artisan config:clear
  2. php artisan cache:clear
  3. Dropped the current database & created a new one with the same name

But all in vain....

I'm using Laravel Framework 6.20.42

Ubuntu 20.04

Digital Ocean

0 likes
16 replies
knubbe's avatar

Can you share a part of .env file with database related data?

mirzaabdulahizhar's avatar

@knubbe Sure, DB_CONNECTION=mysql

DB_HOST=******************

DB_PORT=25060

DB_DATABASE=teekit

DB_USERNAME=******

DB_PASSWORD=************

MYSQL_ATTR_SSL_CA=/etc/ssl/certs/ssl-cert-snakeoil.pem

knubbe's avatar

@mirza-mam Sorry, I didn't expect that you will share production .env

Tray2's avatar

@mirza-mam It looks like the database does not exist on you db-server. Make sure that it's created and if it is make sure you have the correct database name in you env

DB_DATABASE=teekit
knubbe's avatar

@mirza-mam It looks like there is no database with name teekit

Tray2's avatar

@mirza-mam open your database editor of choice and run the following command and show us the output

show databases;

Make sure that you run it on your DO server.

mirzaabdulahizhar's avatar

@Tray2 mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| sys |

| teekit |

+--------------------+

Tray2's avatar

@mirza-mam and that is the DO server and not your local machine?

If so make sure you have the correct host and the correct port in your env file.

1 like
knubbe's avatar

@mirza-mam In that case other credentials are problem (host, path...)

mirzaabdulahizhar's avatar
Level 3

@Tray2 Actually, the problem was resolved. The reason I was continuously facing this problem was that, I was trying to create a Database from Ubuntu > mysql > CREATE DATABASE db_name command but in actual I have to create a database from my mysql db Users & Databases option.

In Digital Ocean the steps were like this:-

  1. Login into your account.
  2. Click your DB.
  3. Goto Users & Databases.
  4. Scroll down to "Databases".
  5. Here add a new db name according to your requirements. And the problem is solved :)
1 like

Please or to participate in this conversation.