1

I'm trying to connect an Express app to MariaDB, both running on localhost.

I have the following code in an Express app:

const mariadb = require('mariadb');
const pool = mariadb.createPool({
     user: 'testuser', 
     password: 'password',
     database: 'test',
     connectionLimit: 5
});

I can connect using 'testuser' from the MariaDB command line, but when Express executes the code above, I see the following in the console:

SQLError: (conn=63, no: 1698, SQLState: 28000) Access denied for user 'testuser'@'localhost'
...
code: 'ER_ACCESS_DENIED_NO_PASSWORD_ERROR'

I have tried setting the testuser password to ''. Have also tried using root user credentials. I always get the same NO_PASSWORD error.

I am running this in Ubuntu 18.04 within Windows Subsystem for Linux/WSL.

Any help is appreciated.

KenP
  • 11
  • 1
  • That's configuring the connection "pool"; what about the connection, itself? – Rick James Dec 14 '19 at 21:55
  • conn = await pool.getConnection(); is what is used inside of an async function. But the result with or without this is the same. It always fails the same way. I am thinking there is something wrong with the MariaDB installation. I'm going to uninstall and re-install. – KenP Dec 15 '19 at 03:46
  • 1
    since host is not set, localhost will be used. I wonder how a MariaDB install on that sub linux identify user coming from localhost. Trying to create a user with '%' might be worth a try – Diego Dupin Jan 06 '20 at 15:33
  • @DiegoDupin creating a new user with % worked for me. Thanks! – SLLegendre May 09 '21 at 09:47

0 Answers0