-1

I made a small project in laravel using MAMP, and everything works fine.

Now I'd like to put the project online. I copied the project with FTP and changed the database.php file.

'mysql' => [
        'driver'    => 'mysql',
        'host'      => env('DB_HOST', 'private.be.mysql'),
        'database'  => env('DB_DATABASE', 'private_be'),
        'username'  => env('DB_USERNAME', 'private_be'),
        'password'  => env('DB_PASSWORD', 'private'),
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
        'strict'    => false,
    ],

The installation works fine when visiting the website, but when visiting a page that uses a connection to the database I get following error.

SQLSTATE[42S02]: Base table or view not found: 
1146 Table 'private_be.users' doesn't exist (SQL: select * from `users`)

So I found out I had forgot to migrate my project. But when typing the command 'php artisan migrate' I get the following error in terminal.

[ErrorException]                                                             
PDO::__construct(): php_network_getaddresses: getaddrinfo failed: nodename   
nor servname provided, or not known 

At first I thought maybe my settings for 'mysql' were incorrect, but I'm sure they are.

My .env file looks like this

APP_ENV=local
APP_DEBUG=true
APP_KEY=***

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

Anybody who can help me fixing the migrate error?

Viktor De Bock
  • 139
  • 1
  • 2
  • 17
  • Are you supposed to have `env` variables for `DB_HOST`, `DB_DATABASE` ect? Right now, your mysql server is located on `private.be.mysql`, as that is the default provided. – Tim Lewis Nov 11 '15 at 18:50
  • No I deleted the DB_HOST, ... variables in env so I was sure it was connecting by using database.php. – Viktor De Bock Nov 11 '15 at 18:53
  • Ok, that's fine, I was just checking to make sure you actually wanted to use those settings. To me, it looks like it can't find mysql on `private.be.mysql`, but beyond that, I'm not sure... – Tim Lewis Nov 11 '15 at 18:54

1 Answers1

3

Sounds like you didn't run your database migrations.

After you moved the files over, did you SSH into the server and go to your project directory and run the command

php artisan migrate

Running the above command will create all database tables you created migrations for. If you already have some data that needs to be rolled back first then rebuilt you can use:

php artisan migrate:refresh

JustinM151
  • 744
  • 3
  • 11
  • I'm doing the 'php artisan migrate' command on the project locally. Might this be my problem? – Viktor De Bock Nov 11 '15 at 18:56
  • You need to run the migrate command on the server that is running the site. Sorry Tim, I did in fact see he ran the command, that's why I checked he was SSH'ed into the server and also included the bit about running a refresh. No need to be rude. – JustinM151 Nov 11 '15 at 18:58
  • That's fair. My bad. Kinda assumed he was running that command on the correct server... – Tim Lewis Nov 11 '15 at 18:59
  • After SSH'ing to the the server I was able to do the migrate command. Thank you! – Viktor De Bock Nov 11 '15 at 19:07