I have a project on local host (xampp) and I want o connect database on server (hostinger.com) with this project, but I don't know? Can anyone help me? Thank so much.
Asked
Active
Viewed 2,040 times
1
-
1You need to put `Database name` and `database host` in your `.env` file or directly in your `database.php` – Faouzi Oudouh Dec 19 '16 at 08:49
-
What does not work? – Robin Dirksen Dec 19 '16 at 08:49
-
@RobinDirksen It's seem to error PDOException in Connector.php line 55: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No such host is known. – Mr D Dec 19 '16 at 08:53
-
@FaouziOudouh above is my env file and I putted correct db_name and db_host – Mr D Dec 19 '16 at 08:55
-
1Did you setup a "allow host", this is you public ip. https://www.hostinger.co.uk/knowledge-base/839 http://www.whatsmyip.org/ – Robin Dirksen Dec 19 '16 at 08:56
-
@RobinDirksen I didn't known setup allow host. Can you help me that? – Mr D Dec 19 '16 at 09:03
-
Why won't you export DB and build with code on localhost? I don't think it(your way) a right thing to do - just my idea. – Henry Bui Dec 19 '16 at 09:12
-
1@Dung for the best performance you need to run the database on you local machine, otherwise the requests may take 3 times so long... – Robin Dirksen Dec 19 '16 at 09:23
-
@BuiVietHuong I want this project upload to server not change database config. – Mr D Dec 19 '16 at 09:40
-
@RobinDirksen ok, thanks for your idea. I only want this is easer when I upload this project to server. – Mr D Dec 19 '16 at 09:49
-
@Dung you can setup a .env file that's only for your server, and you have a local .env file. – Robin Dirksen Dec 19 '16 at 09:53
-
@RobinDirksen I will note it when I deploy my app. – Mr D Dec 19 '16 at 10:02
1 Answers
0
Please use it may be working. Put value DB_DATABASE,DB_USERNAME & DB_PASSWORD see below.
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://hostinger.com/
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE= your database name here
DB_USERNAME= your database username here
DB_PASSWORD= your database password here
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

Md.Jewel Mia
- 3,345
- 3
- 19
- 24
-
I did this but it still not working. And here is error from page SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No such host is known. – Mr D Dec 19 '16 at 09:46
-
Please flow it. Laravel 4: Change "host" in the app/config/database.php file from "localhost" to "127.0.0.1" Laravel 5: Change "DB_HOST" in the .env file from "localhost" to "127.0.0.1" – Md.Jewel Mia Dec 19 '16 at 09:49
-
1Please see link http://stackoverflow.com/questions/20723803/pdoexception-sqlstatehy000-2002-no-such-file-or-directory – Md.Jewel Mia Dec 19 '16 at 09:52
-