![](/img/trans.png)
[英]I'm using Laravel 5 and I'm not being able to migrate my database using php artisan migrate
[英]php artisan migrate can not find my database
我已經創建了名為resume_manager
MySQL 數據庫我的數據庫用戶名是root
,密碼是password
但是當我運行php artisan migrate
,會顯示下面的錯誤消息。
Illuminate\Database\QueryException : SQLSTATE[HY000] [1049] Unknown database 'resume_manager' (SQL: select * from information_schema.tables where table_schema = resume_manager and table_name = migrations)
at /home/geralt/Music/resume-manager/vendor/laravel/framework/src/Illuminate/Database/Connection.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[HY000] [1049] Unknown database 'resume_manager'")
/home/geralt/Music/resume-manager/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68
2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=resume_manager", "root", "password", [])
/home/geralt/Music/resume-manager/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68
Please use the argument -v to see more details.
我在 Xampp 上運行 MySQL。 我檢查過 my.cnf 文件端口設置為默認的3306
我不知道發生了什么。 順便說一下,我正在使用Linux Mint
。 而且我還運行了有關cache
所有命令
php artisan cache:clear
php artisan route:cache
php artisan config:clear
php artisan view:clear
這是我的.env
文件設置:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=resume_manager
DB_USERNAME=root
DB_PASSWORD=password
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
從錯誤中可以確定您的端口、用戶名和密碼沒有問題,它們都是正確的……所以只需仔細檢查resume_manager
存在;
簡單地轉到您的 mysql 控制台並創建一個空數據庫
mysql> CREATE DATABASE resume_manager;
或者
你也使用 phpmyadmin 做同樣的事情......
如果數據庫已經存在,它將給出錯誤,否則將創建新的必需數據庫...(您的舊數據庫名稱中可能存在一些拼寫錯誤)
嘗試新建數據庫,如果同樣的問題再次發生,你可以使用這個命令
php artisan config:cache
每當我們更改.env
文件中的DB_DATABASE
、 DB_USERNAME
和DB_PASSWORD
時,我們需要清除緩存: php artisan config:cache
運行 migrate Artisan 命令后: php artisan migrate
更改.env
文件后始終清除配置
php artisan config:cache
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.