尝试使用vagrant

时间:2015-06-17 09:03:19

标签: php mysql yii vagrant virtualbox

我使用Vagrant在Windows中启动VirtualBox VM。我这样做:

$ vagrant ssh

连接到VM。然后我$ mysql连接到我的数据库。然后我可以看到我创建的数据库以供使用。但是,当我进入我的服务器时,我看到了这个错误:

The table "doe_user" for active record class "User" cannot be found in the database.

我知道这是因为数据库是空的并且表User不存在。这就是为什么我尝试使用以下方法将表添加到数据库中:

load all tables in the doe_db:        http://***.***.**.**/install.php;

当我跑步时,我得到:

mysql> load all tables in the doe_db:     http://***.***.**.**/install.php;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'all t
ables in the doe_db:     http://***.***.**.**/install.php' at line 1,

当我使用show databases时,我选择了正确的数据库,然后要求显示它返回空集的表。

当我去http://***.***.**.**/install.php时,我得到了:

Internal Server Error

Undefined index: log

An internal error occurred while the Web server was processing your request. Please contact the webmaster to report this problem.

Thank you.

这是我的数据库代码:

$config_database = array(
        'components' => array(
                'db' => array(
                        'connectionString'   => 'mysql:host=localhost;dbname=doe_db',
                        'emulatePrepare'     => true,
                        'username'           => 'root',
                        'password'           => 'root',
                        'charset'            => 'utf8',
                        'enableProfiling'    => true, //http://www.yiiframework.com/doc/guide/1.1/en/topics.logging
                        'enableParamLogging' => true,
                ),
        ),
);

现在,当我访问时:http://***.***.**.**/index.php

我收到错误:

The table "doe_user" for active record class "User" cannot be found in
the database.

但是,当我将数据库代码更改为:

$config_database = array(
        'components' => array(
                'db' => array(
                        'connectionString'   => 'mysql:host=localhost;dbname=doe_db',
                        'emulatePrepare'     => true,
                        'username'           => 'root',
                        'password'           => '',
                        'charset'            => 'utf8',
                        'enableProfiling'    => true, //http://www.yiiframework.com/doc/guide/1.1/en/topics.logging
                        'enableParamLogging' => true,
                ),
        ),
);

当我访问时:http://***.***.**.**/index.php我得到:

CDbConnection failed to open the DB connection: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)

对于我的本地主机,当我想访问phpMyAdmin时,我的root用户没有任何密码。

1 个答案:

答案 0 :(得分:0)

您可以参考MySQL - LOAD DATA INFILE加载文件中的数据。

LOAD DATA INFILE 'http://***.***.**.**/install.php' INTO TABLE doe_db;