简体   繁体   中英

Can't migrate in laravel

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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