we use rds when we use AWS cloud .
but we also can use install mysql on ec2
sudo apt-get update
sudo apt-get install -y mysql-server
so mysql 5.7 is installed.
if you want mysql version 8.0 👇
wget -c https://repo.mysql.com//mysql-apt-config_0.8.13-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb
and you write down command sudo apt-get update
sudo apt-get install mysql-server
mysql_secure_installation
you have to set your mysql password
if you want to get rid of the error , at the cost of risking the security of the project
alter user 'root'@'localhost' identified with mysql_native_password by 'password';
flush privilegs;
if you want to have a fix for it , without knowing why , just install and use mysql2
(instead of mysql) and use it
npm install mysql2
mysql = require('mysql2');