Member-only story
Connect MySQL Database From Electron Application

When developing desktop application maybe sometime best database we can use is sqlite, because it simple and also easy to implement, in my case found one problem where sqlite is unstable.
For the information now i’m developing the application using MacOs and also windows, in my MacOs sqlite running very well but on my windows laptop they can showing error message like.
windows sqlite crashpad_client_win.cc(844)
based on this case, i decide to change my database to mysql for current project development, i installing XAMPP or Laragon on my client device and also as mysql server, let’s to step by step by step how to implement it.
For infomation for my project i use vite-electron-react by following https://electron-vite.org/guide/
- Install MySQL pluggin
To use mysql sql on we can use mysql2 plugin and install only by one command
npm install --save mysql2
// typescript
npm install --save-dev @types/node
2. Configure Database Connection
create one file in electron/database.config.ts
export default {
HOST: "localhost",
USER: "root",
PASSWORD: undefined,
DATABASE: "database",
};