0

I am new to all three Electron Mysql and JS

I was trying to connect to my database "school" with table "student"

Kindly help

Index.js

const electron = require('electron')
const { app, BrowserWindow } = electron
const url = require('url')
const path = require('path')
app.on('ready', _ => {
    var mysql = require('mysql')
    var connection = mysql.createConnection({
       host  : 'localhost',
       users : 'root',
       password: '123456',
       database: 'school'
    })
    connection.connect(function(err) {
       if (err) {
         console.error('error connecting: ' + err.stack)
         return
       }
       console.log('connected as id ' + connection.threadId)
    })
})

Screenshot of Error attached

enter image description here

1 Answers1

1

Your connection profile is wrong, there is no users option. this is the working profile >

let connection = mysql.createConnection({
     host  : 'localhost',
     user : 'root',
     password: '123456',
     database: 'school'
  })

You can check npm mysql docs from here

namila007
  • 1,044
  • 9
  • 26