Mysql 即使安装了 Laravel-homestead 也找不到
Mysql not found even the Laravel-homestead is installed
我是 Laravel 和 PHP 的新手。现在我希望 link 我的 Laravel 项目到 Mysql 数据库。我正在使用 os x 10.10,我已经安装了 homestead
和 vagrant
。但是当我在命令行中输入which mysql
时,却被告知mysql not found
。
mysql 数据库支持 osed 包含在 homestead 包中。但是为什么找不到mysql呢?我怎样才能 link 我的项目到 mysql 数据库,我怎样才能确保我已经成功做到了?提前致谢!
如果我猜对了,你正试图在你的 物理机 上找到 mysql,而它实际上安装在你的 虚拟机 。您必须先通过 ssh 连接到 Homestead,才能执行 which mysql
。所以在你的终端做:
homestead up
homestead ssh
which mysql
您可以在文档中阅读更多关于 Homestead 的信息 documentation. Also you can read wiki article 以跟上虚拟机的概念。
要在 Homestead 中创建一个新数据库,您只需找到 Homestead.yaml 文件(通常路径是 ~/.homestead/Homestead.yaml)并将您的数据库名称添加到数据库部分:
databases:
- homestead
- your_new_database_name
然后你必须使用 homestead provision
配置 Homestead 机器。在此之后,将创建数据库,您唯一需要做的就是从您的项目 .env
文件(位于您的 Laravel 项目的根目录中)link 到它:
DB_HOST=localhost
DB_DATABASE=your_new_database_name
DB_USERNAME=homestead
DB_PASSWORD=secret
这个不得不做。 Laravels documentation regarding database is really great. Usually you can find all you need there. I guess you will need to create some migrations to create the schema for you databases. It is covered there也是。
我是 Laravel 和 PHP 的新手。现在我希望 link 我的 Laravel 项目到 Mysql 数据库。我正在使用 os x 10.10,我已经安装了 homestead
和 vagrant
。但是当我在命令行中输入which mysql
时,却被告知mysql not found
。
mysql 数据库支持 osed 包含在 homestead 包中。但是为什么找不到mysql呢?我怎样才能 link 我的项目到 mysql 数据库,我怎样才能确保我已经成功做到了?提前致谢!
如果我猜对了,你正试图在你的 物理机 上找到 mysql,而它实际上安装在你的 虚拟机 。您必须先通过 ssh 连接到 Homestead,才能执行 which mysql
。所以在你的终端做:
homestead up
homestead ssh
which mysql
您可以在文档中阅读更多关于 Homestead 的信息 documentation. Also you can read wiki article 以跟上虚拟机的概念。
要在 Homestead 中创建一个新数据库,您只需找到 Homestead.yaml 文件(通常路径是 ~/.homestead/Homestead.yaml)并将您的数据库名称添加到数据库部分:
databases:
- homestead
- your_new_database_name
然后你必须使用 homestead provision
配置 Homestead 机器。在此之后,将创建数据库,您唯一需要做的就是从您的项目 .env
文件(位于您的 Laravel 项目的根目录中)link 到它:
DB_HOST=localhost
DB_DATABASE=your_new_database_name
DB_USERNAME=homestead
DB_PASSWORD=secret
这个不得不做。 Laravels documentation regarding database is really great. Usually you can find all you need there. I guess you will need to create some migrations to create the schema for you databases. It is covered there也是。