[英]php artisan migrate can not find my database
I've created MySQL database named resume_manager
My DB username is root
and password is password
But when I run php artisan migrate
The error message bellow is showing.我已经创建了名为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.
I'm running MySQL on Xampp.我在 Xampp 上运行 MySQL。 I've checked my.cnf file port is set to the default 3306
I don't know what's going on.我检查过 my.cnf 文件端口设置为默认的3306
我不知道发生了什么。 By the way I'm using Linux Mint
.顺便说一下,我正在使用Linux Mint
。 And I also ran all the commands regarding cache
而且我还运行了有关cache
所有命令
php artisan cache:clear
php artisan route:cache
php artisan config:clear
php artisan view:clear
This is my .env
file setup:这是我的.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}"
From the error it is sure that there is no problem with you port, username and password they all are correct... so just double check resume_manager
exist or not else;从错误中可以确定您的端口、用户名和密码没有问题,它们都是正确的……所以只需仔细检查resume_manager
存在;
simple go to your mysql console and create an empty database简单地转到您的 mysql 控制台并创建一个空数据库
mysql> CREATE DATABASE resume_manager;
or或者
you do the same using phpmyadmin too...你也使用 phpmyadmin 做同样的事情......
if database already exist it will give error else new required db will be created... (there might be some typo issue in your old db name)如果数据库已经存在,它将给出错误,否则将创建新的必需数据库...(您的旧数据库名称中可能存在一些拼写错误)
尝试新建数据库,如果同样的问题再次发生,你可以使用这个命令
php artisan config:cache
Whenever we change the DB_DATABASE
, DB_USERNAME
and DB_PASSWORD
in .env
file, we need to clear the cache: php artisan config:cache
每当我们更改.env
文件中的DB_DATABASE
、 DB_USERNAME
和DB_PASSWORD
时,我们需要清除缓存: php artisan config:cache
After you can run the migrate Artisan command: php artisan migrate
运行 migrate Artisan 命令后: php artisan migrate
更改.env
文件后始终清除配置
php artisan config:cache
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.