Laravel 初期設定

# php artisan key:generate
Application key set successfully.
# vim -R .env
APP_KEY=base64:WaC*********************************************************
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| phpmyadmin         |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> create database laravel_db default character set utf8;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| laravel_db         |
| mysql              |
| performance_schema |
| phpmyadmin         |
+--------------------+
5 rows in set (0.00 sec)

MariaDB [(none)]> grant all privileges on laravel_db.* to laravel@localhost identified by '********';
Query OK, 0 rows affected (0.00 sec)
# vim .env
    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=laravel_db
    DB_USERNAME=laravel
    DB_PASSWORD=********
# pwd
/var/www/html/test1/config
# vim app.php
'timezone' => 'Asia/Tokyo',
'locale' => 'ja',
# vim database.php
'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'laravel_db'),
            'username' => env('DB_USERNAME', 'laravel'),
            'password' => env('DB_PASSWORD', '********'),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8',
            'collation' => 'utf8_general_ci',
 ~(中略)~
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

DB接続確認

# php artisan migrate
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated:  2014_10_12_000000_create_users_table
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated:  2014_10_12_100000_create_password_resets_table

f:id:hirose-test:20190625202638p:plain

起動していたLaravel (# php artisan serv --host=172.16.3.* --port=**)を一旦 Ctrl+C で停止させ、再起動する。

『もし終了せずにターミナルを閉じてしまった時』
php artisan serveを停止させる方法 - Qiita

その後、REGISTERから登録してみる。 できた。

f:id:hirose-test:20190625203443p:plain

MariaDB [laravel_db]> select * from users\G
*************************** 1. row ***************************
               id: 1
             name: hirose
            email: shin****************@gmail.com
email_verified_at: NULL
         password: $2y$10$************************************************
   remember_token: NULL
       created_at: 2019-06-25 20:32:10
       updated_at: 2019-06-25 20:32:10
/* -----codeの行番号----- */