简体   繁体   English

Laravel 应用程序在部署到实时服务器后未连接

[英]Laravel app not connecting after deployment to live server

After deploying my Laravel app to inMotion hosting, I am having issues connecting to the database.将我的 Laravel 应用程序部署到 inMotion 主机后,我在连接数据库时遇到问题。 What is strange is that if I use a PHP script to test the connection, it works.奇怪的是,如果我使用 PHP 脚本来测试连接,它就可以工作。 However, when trying to login I get this error:但是,在尝试登录时出现此错误:

 SQLSTATE[HY000] [1045] Access denied for user @'localhost' (using password: YES) (SQL: select * from `users` where `email` =.com limit

I am using the exact same username and password in the.env file as I did in the PHP test script.我在 .env 文件中使用与在 PHP 测试脚本中完全相同的用户名和密码。 I have tried clearing the cache and also changing the password for the database as well as my username.我已经尝试清除缓存并更改数据库的密码以及我的用户名。

Better if you can clear the config cache and see.如果您可以清除配置缓存并查看,那就更好了。 You can use the following command to clear the config cache in Laravel:您可以使用以下命令清除 Laravel 中的配置缓存:

php artisan config:cache

Turns out it was the password in the.env file.原来是 .env 文件中的密码。 It had special characters, so I had to add quotation marks around it.它有特殊字符,所以我不得不在它周围添加引号。

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

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