我正在建立一个Laravel环境。所以,我下载了XAMPP并相应地配置了我的vhost文件。然后,我设置MySQL并运行以下命令:
之后,运行4号,我在图片中收到以下错误。
C:\Users\Aslam\Desktop\Pfera_application\pfera-web>php artisan migrate -v
Illuminate\Database\QueryException : SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = forge and table_name = migrations)
at C:\Users\Aslam\Desktop\Pfera_application\pfera-web\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:
669: return $result;
Exception trace:
1 Doctrine\DBAL\Driver\PDOException::("SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: YES)")
C:\Users\Aslam\Desktop\Pfera_application\pfera-web\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php : 50
请帮忙!!!非常感谢!
PS,这是database.php文件:
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
],
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer set of commands than a typical key-value systems
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
'client' => 'predis',
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
];
这是我的.env文件:
## REAL KEY REMOVED FOR PLAIN TEXT TRANSFER
## SEE http://laravel-recipes.com/recipes/283/generating-a-new-application-key FOR GENERATING YOUR OWN KEY, DO THIS BEFORE RUNNING ANY SEEDS
APP_NAME=Pfera
APP_ENV=staging
APP_KEY=base64:E8vEONwbkikyy/7IsRpNg/kakuRy3/JCUjetkpH1EzE=
APP_DEBUG=false
APP_LOG_LEVEL=debug
APP_URL=pfera.local
## THESE ARE DB CREDS THAT ARE SPECIFIC TO YOUR OWN DATABASE
## REAL PASSWORD REMOVED FOR PLAIN TEXT TRANSFER
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=forge
DB_USERNAME=forge
DB_PASSWORD=password
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
## REAL MAILGUN SECRET REMOVED FOR PLAINT TEXT TRANSFER
## THIS IS FOR CODE AND MORTAR'S DEVELOPMENT ACCOUNT, UNIQUE CREDENTIALS WILL
## NEED TO BE CREATED FROM YOUR OWN ACCOUNT FOR PRODUCTION, LOCAL DEVELOPMENT,
## AND ONCE THE STAGING ENVIRONMENT IS FULLY TRANSITIONED
MAIL_DRIVER=mailgun
MAILGUN_DOMAIN=mg.codeandmortar.com
MAILGUN_SECRET=12345678
MAIL_FROM_NAME="Pfera"
MAIL_FROM_ADDRESS="no-reply@pfera.ca"
MAIL_FROM="no-reply@pfera.ca"
## THESE ARE ALL VARIABLES FOR SPARK FEATURES NOT IMPLEMENTED IN THIS PHASE
PUSHER_KEY=
PUSHER_SECRET=
PUSHER_APP_ID=
AUTHY_SECRET=
STRIPE_MODEL=App\User
STRIPE_KEY=
STRIPE_SECRET=
BRAINTREE_MODEL=App\User
BRAINTREE_ENV=
BRAINTREE_MERCHANT_ID=
BRAINTREE_KEY=
BRAINTREE_SECRET=
## END NON-IMPLEMENTED SPARK VARIABLES
## PAGINATION
HORSES_PER_PAGE=20
EVENTS_PER_PAGE=20
TESTS_PER_PAGE=20
USERS_PER_PAGE=20
## ESTIMATED ESTROUS CYCLE LENGTH IN DAYS
ESTROUS_CYCLE=21
## VARIABLES THE POINT OUT:
## 1) THE PATH TO THE `Rscript` EXECUTABLE TO RUN R CODE
## 2) THE PATH TO THE R CODE REPO
## 3) THE FILENAME OF THE R CODE TO RUN
## NOTE THAT ON THE SERVER WE'RE USING `chroot` SINCE THE R AND PHP UBUNTU
## BINARIES HAD CONFLICTING DEPENDENCIES, THIS IS WHY THE "RELATIVE" PATH FOR
## THE R SCRIPT IS JUST `.`, BECAUSE IT IS WITHIN THE ROOT OF THE CHROOT JAIL.
## THIS WILL ALMOST DEFINITELY NOT BE THE CASE IN LOCAL DEVELOPMENT. FOR LOCAL
## DEVELOPMENT, I WOULD STRONGLY RECOMMEND PROVING `R_PREDICT_PATH` A FULL PATH
## TO THE DIRECTORY THAT CONTAINS THE R CODE (THIS PATH MUST NOT INCLUDE THE R
## FILE ITSELF)
RSCRIPT_BIN="chroot /var/chroot Rscript"
R_PREDICT_PATH=/c/Users/Aslam/Desktop/Pfera_application/pfera-r
R_PREDICT_FILE=predict.R
答案 0 :(得分:1)
Laravel仍在尝试使用默认的Forge配置。您需要打开.env
和config/database.php
文件并配置MySQL的连接信息。
您的config/database.php
文件很可能已经为MySQL配置,因此我将主要介绍您的.env
文件。存在.env
文件,因此您可以为开发和生产环境定义不同的选项。
在.env
文件中,配置如下:
DB_CONNECTION=mysql
DB_TEST_DATABASE=database_name
DB_TEST_USERNAME=mysql_user_with_access_to_the_database
DB_TEST_PASSWORD=your_super_secure_password
默认情况下,config/database.php
文件设置为从.env
文件中提取此信息。如果.env
文件不存在,则会有自己的后备信息。
答案 1 :(得分:1)
如果您确定数据库用户和密码,那么这是一个连接错误,然后尝试退出cli中的工匠服务器并重新运行
DB_DATABASE=forge
DB_USERNAME=root
DB_PASSWORD=
如果您不确定您的用户名或密码,并且您正在使用带有流浪汉的宅基地
尝试以下
.pickup-location-field small {
display: none;
}
如果您不确定您的密码和用户名而不使用vagrant homestead
试试这个
gene_symbol <- c("DADA", "SDAASD", "SADDSD", "SDADD")
panel <- c("growth", "growth", "big", "small")
ASDDA <- c("normal", "over", "low", "over")
ASDDb <- c("normal", "over", "low", "over")
ASDDAf <- c("normal", "over", "low", "over")
Gene_states22 <- data.frame(gene_symbol, panel, ASDDA, ASDDb, ASDDAf)
答案 2 :(得分:0)
您的错误相关的laravel {% extends 'base.html' %}
{% block content %}
<nav aria-label="breadcrumb">
</nav>
<h2 class="mb-3">My Items list</h2>
<div class="card">
<table class="table mb-0">
<thead>
<tr>
<th>Name</th>
<th>Department</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
{% for a in abcs %}
<tr>
<td class="align-middle">{{ a.name }}</td>
<td class="align-middle">{{ a.department.get_html_badge }}</td>
<td class="align-middle badge badge-pill badge-danger">{{ a.status }}</td>
</tr>
{% empty %}
{% endfor %}
</tbody>
</table>
</div>
<h2 class="mb-3">My Expired Items list</h2>
<div class="card">
<table class="table mb-0">
<thead>
<tr>
<th>Name</th>
<th>Department</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
{% for b in expired_item %}
<tr>
<td class="align-middle">{{ b.name }}</td>
<td class="align-middle">{{ b.department.get_html_badge }}</td>
<td class="align-middle badge badge-pill badge-danger">{{ a.status }}</td>
</tr>
{% empty %}
{% endfor %}
</tbody>
</table>
</div>
<div class="card-footer">
{% endblock %}
与DB的配置
.env
答案 3 :(得分:0)
数据库连接数据在config / database.php文件中定义,mysql行是这样的:
'host' => env('DB_HOST', 'localhost'),
其中第一个参数表示从.env文件获取此值,并且出于任何原因,如果它无法加载该信息,请使用第二个参数。 所以你应该在两个文件中定义你的凭证。
如果没有帮助使用
'host' => 'localhost',
对应于每行数据库配置行