Sunday 1 March 2020

Lumen tutorial

Tutorial
https://auth0.com/blog/developing-restful-apis-with-lumen/

This link looks easy and thorough as well.
https://medium.com/@Dotunj/building-a-rest-api-with-lumen-403b67fec4d6

Following above url, I had below error.

Ins-MacBook-Pro:authors inheeoh$ php artisan make:migration create_authors_table
Created Migration: 2020_03_01_103525_create_authors_table
Ins-MacBook-Pro:authors inheeoh$ php artisan migrate

In Connection.php line 669:
                                                                                                                                    
  SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from information_schema.t  
  ables where table_schema = matthew_schema and table_name = migrations and table_type = 'BASE TABLE')                              
                                                                                                                                    

In Connector.php line 70:
                                                                                           
  SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client  
                                                                                           

In Connector.php line 70:
                                                                                                                
  PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]  
                                                                                                                


I found the error reason is from my MySQL version 8.0


mysql> CREATE USER 'user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword';
Query OK, 0 rows affected (0.04 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

And changed .env file to use:
DB_DATABASE=matthew_schema
DB_USERNAME=user
DB_PASSWORD=yourpassword

mysql> select host, user from mysql.user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
| localhost | root             |
| localhost | user             |
+-----------+------------------+
5 rows in set (0.00 sec)



Finally success!

Ins-MacBook-Pro:authors inheeoh$ php artisan migrate
Migration table created successfully.
Migrating: 2020_03_01_103525_create_authors_table
Migrated:  2020_03_01_103525_create_authors_table (0.01 seconds)
Ins-MacBook-Pro:authors inheeoh$ 




Running tutorial on AWS Ubuntu live server
While creating 'authors' project, I had below error.

phpunit/phpunit 8.5.x-dev requires ext-dom * -> the requested PHP extension dom is missing from your system.

Found solution
You have to install php-xml

I also had below error.
The following exception is caused by a lack of memory or swap, or not having swap configured


Run below site with sudo.
https://stackoverflow.com/questions/38828224/composer-update-the-following-exception-is-caused-by-a-lack-of-memory-and-not-h

ubuntu@ip-172-31-16-44:~$ sudo /sbin/mkswap /var/swap.1
mkswap: /var/swap.1: insecure permissions 0644, 0600 suggested.
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=ac8bde7a-0271-4a81-913d-66c3e5117556
ubuntu@ip-172-31-16-44:~$ sudo /sbin/swapon /var/swap.1
swapon: /var/swap.1: insecure permissions 0644, 0600 suggested.

Then I could install lumen >> authors project successfully !


No comments:

Post a Comment