![](/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.