I have a MySQL database setup on my Raspberry Pi 4, and it works perfectly when I execute the code on my Raspberry PI. But I want to code on my Windows 10 PC, so I copied the database connection code and pasted it on my Windows PC. When I run the code it gives me this error:
[nodemon] starting `node ./database/db.js`
Error: Access denied for user 'lasse'@'localhost' (using password: YES)
at Object.createConnection (C:\Users\Lasse\Desktop\rradvanced\node_modules\mysql2\promise.js:241:31)
at Object.<anonymous> (C:\Users\Lasse\Desktop\rradvanced\database\db.js:3:7)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'ER_ACCESS_DENIED_ERROR',
errno: 1045,
sqlState: '28000'
The code:
const mysql = require('mysql2/promise')
mysql.createConnection({
user: 'lasse',
password: '',
database: 'rradvanced'
}).then((connection) => {
connection.execute('CREATE TABLE Guilds(guildId VARCHAR(255))')
})
.then(() => console.log('Database succesfully connected'))
.catch(err => console.log(err));
The Raspberry PI and my Windows PC run on the same internet.