Should DB_HOST be changed to 127.0.0.1?
P粉514001887
P粉514001887 2023-08-26 17:50:38
0
2
601
<p>So I'm using XAMPP and Laravel 5.x with PHP 7.4 and when I load my local server, I run into an error and can't access the database on my system. When I searched online, the answer I found said to change the local <code>DB_HOST</code> address in the <code>database.php</code> file to <code>127.0.0.1< ;/code> instead of setting it to localhost because MYSQL will use TCP instead of a UNIX socket to connect. Will it cause problems if I push this change to staging or production servers? </p>
P粉514001887
P粉514001887

reply all(2)
P粉587780103

Laravel uses the DotEnv library to configure different environments. You can follow the Laravel documentation to generate .env files for each environment (local and development server).

P粉986860950

On a real server, you need to connect to the database server that contains the database used by the application, Therefore the .env configuration related to the database needs to be changed to the actual database server

DB_HOST=[这里是数据库服务器IP]
DB_PORT=3306
DB_DATABASE=[数据库名称]
DB_USERNAME=[用户名]
DB_PASSWORD=[用户密码]

What you need to read about Laravel Project Deployment

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!