简体   繁体   English

我无法使用mysql端口号3306访问数据库并在laravel项目中迁移

[英]I can't access database and migrate in laravel project using port number 3306 for mysql

The first picture is the database config in .env file and the port number is 3306 第一张图片是.env文件中的数据库配置,端口号是3306

The second picture is the database config in /config/database.php file 第二张图片是/config/database.php文件中的数据库配置

The third picture is the database config in mysql workbench 第三张图是mysql工作台中的数据库配置

I cannot migrate the model and access database when the port number set to 3306 in .env file, while if set to 33060 it can access. 当.env文件中的端口号设置为3306时,我无法迁移模型并访问数据库,而如果将端口号设置为33060,则它可以访问。

And it generated error "Illuminate\\Database\\QueryException : SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrations)" when I try to run "php artisan migrate". 并生成错误“ Illuminate \\ Database \\ QueryException:SQLSTATE [HY000] [1045]用户'homestead'@'localhost'的访问被拒绝(使用密码:是)(SQL:从information_schema.tables中选择*,其中table_schema = homestead和table_name =迁移)”,当我尝试运行“ php artisan migration”时。

I tried a lot of methods but still encounter the same problem when using port 3306. 我尝试了很多方法,但是在使用端口3306时仍然遇到相同的问题。

Vagrant box will not run on localhost(127.0.0.1) like you specified in your .env file, you must specify the ip_address on which you can reach vagrant by putting in your vagrantfile Vagrant框将不会像在.env文件中指定的那样在localhost(127.0.0.1)上运行,您必须通过放入vagrantfile来指定可在其上找到vagrant的ip_address

config.vm.network "public_network", ip: "192.168.1.10"

after that run vagran reload in terminal 之后,在终端运行vagran reload

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM