0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

config/database.php

Last updated at Posted at 2022-03-26

SynogyのNASにはMariaDBがのっている。
config/database.phpの初期設定はutf8mb4という絵文字対応の文字コードになっているため そのままphp artisan migrateすると文字コードがおかしくなる。

config/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', 'forge'), 
'username' => env('DB_USERNAME', 'forge'), 
'password' => env('DB_PASSWORD', ''), 
'unix_socket' => env('DB_SOCKET', ''), 
ここを変更する 'charset' => 'utf8', 
ここを変更する 'collation' => 'utf8_general_ci', 
'prefix' => '',
'prefix_indexes' => true, 
'strict' => true, 
'engine' => null, 
'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
 ]) : [], 
],

configファイルにさわったので

php artisan cache:clear
php artisan config:clear

私は文字化けは経験してないのだがこの設定で今まで問題になったことはない。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?