On my dev environment, I have installed MySQL 8.0 and built the app accordingly, But on the prod server, the MySQL version is 5.7 and my app fails to connect to the database.
I use the mysql2
package because I need the Async API (mysql2/promise
) which is not available in mysql
. I even tried to use mysql-await
which was a port of mysql
with added Async API, but after authenticating to the Database, it just fails to create tables.
What causes this? are there different authentication methods used in MySQL 8.0 and MySQL 5.7? If so, then what method is used by 5.7 and how could I configure the authentication method used in the mysql2
connection?
I connect to the Database like this:
db = await mysql.createConnection({
host: mysql_host,
user: mysql_user,
password: mysql_pass,
database: mysql_db
})
And create tables like this:
await db.query(
"CREATE TABLE IF NOT EXISTS form (ID int NOT NULL AUTO_INCREMENT, \
Name varchar(255), \
Email varchar(255), \
Phone varchar(15), \
Address varchar(255), \
Occupation varchar(50), \
PRIMARY KEY (ID))")