データベースの作成はしました
lang
1 2 3mysql> show databases 4 -> ; 5+-------------------------+ 6| Database | 7+-------------------------+ 8| dotinstall_blog_cakephp | 9| information_schema | 10| mysql | 11| performance_schema | 12| sys | 13+-------------------------+ 145 rows in set (0.00 sec) 15 16mysql> use dotinstall_blog_cakephp; 17Reading table information for completion of table and column names 18You can turn off this feature to get a quicker startup with -A 19 20Database changed 21mysql> show tabels; 22ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tabels' at line 1 23mysql> show tables; 24+-----------------------------------+ 25| Tables_in_dotinstall_blog_cakephp | 26+-----------------------------------+ 27| posts | 28+-----------------------------------+ 291 row in set (0.00 sec) 30 31mysql> select * from posts; 32+----+---------+--------+---------------------+----------+ 33| id | title | body | created | modified | 34+----+---------+--------+---------------------+----------+ 35| 1 | title 1 | body 1 | 2019-08-17 15:50:01 | NULL | 36| 2 | title 2 | body 2 | 2019-08-17 15:50:01 | NULL | 37| 3 | title 3 | body 3 | 2019-08-17 15:50:01 | NULL | 38+----+---------+--------+---------------------+----------+ 393 rows in set (0.00 sec) 40 41mysql> 42
config/app.phpにて設定
langconfig/app.php
1 2'Datasources' => [ 3 'default' => [ 4 'className' => Connection::class, 5 'driver' => Mysql::class, 6 'persistent' => false, 7 'host' => 'localhost', 8 /* 9 * CakePHP will use the default DB port based on the driver selected 10 * MySQL on MAMP uses port 8889, MAMP users will want to uncomment 11 * the following line and set the port accordingly 12 */ 13 //'port' => 'non_standard_port_number', 14 'username' => 'dbuser', 15 'password' => '**********',パスワードは伏せさせてください 16 'database' => 'dotinstall_blog_cakephp', 17 /* 18 * You do not need to set this flag to use full utf-8 encoding (internal default since CakePHP 3.6). 19 */ 20 'encoding' => 'utf8mb4', 21 'timezone' => 'UTC', 22 'flags' => [], 23 'cacheMetadata' => true, 24 'log' => false, 25
と設定しました。
参考記事です
https://qiita.com/fisherman3110se/items/1d3d50cebecb2c0973ba
CakePHP is NOT able to connect to the database.
Connection to database could not be established: SQLSTATE[HY000] [1045] Access denied for user 'dbuser'@'localhost' (using password: YES)
となっています。どうすればいいでしょうか?
回答1件
あなたの回答
tips
プレビュー