在浏览了一些基本的 laravel 代码之后,我尝试了迁移。以下是我的 app\config\databast.php 文件 -
return array(
'fetch' => PDO::FETCH_CLASS,
'default' => 'mysql',
'connections' => array(
'sqlite' => array(
'driver' => 'sqlite',
'database' => __DIR__.'/../database/production.sqlite',
'prefix' => '',
),
'mysql' => array(
'driver' => 'mysql',
'host' => 'myproject',
'database' => 'myproj',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
'pgsql' => array(
'driver' => 'pgsql',
'host' => 'myproject',
'database' => 'myproj',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
),
'sqlsrv' => array(
'driver' => 'sqlsrv',
'host' => 'myproject',
'database' => 'database',
'username' => 'root',
'password' => '',
'prefix' => '',
),
),
'migrations' => 'migrations',
'redis' => array(
'cluster' => true,
'default' => array(
'host' => '127.0.0.2',
'port' => 6379,
'database' => 0,
),
),
);
如您所见,默认为 mysql 数据库。然后在命令提示符下我尝试了这个。
php artisan migrate:make users
输出是 -
created migration: 2013_08_05_110148_users
Generating optimized class loader
然后我尝试了这个
php artisan migrate:install
但我得到了这样的错误
您可以看到它显示“不允许主机 medismoCRM 连接到此服务器”。medismoCRM 是我在 mysql 服务器中完成的另一个项目。所以我检查了主机文件。主机文件中的行是这样的 -
127.0.0.1 localhost
127.0.0.1 medismoCRM
127.0.0.2 myproject
因此 medismoCRM 和当前项目 myproject 都具有不同的 IP。然后我还检查了 apache 中的 httpd-vhosts.conf 文件。我也有2个这样的不同主机-
<VirtualHost *:80>
DocumentRoot "C:/Program Files/Zend/Apache2/htdocs/laravel-master/public/"
ServerName myproject
<Directory "C:/Program Files/Zend/Apache2/htdocs/laravel-master/public/">
Options Indexes FollowSymLinks
AllowOverride all
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.2
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/Program Files/Zend/Apache2/htdocs/medismoCRM/"
ServerName medismoCRM
<Directory "C:/Program Files/Zend/Apache2/htdocs/medismoCRM/">
Options Indexes FollowSymLinks
AllowOverride all
# onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>
那么当我尝试使用 php artisan migrate:install 时,谁能告诉我为什么命令提示符出现该错误?