MySQL1 [nodeJS] Node.JS와 mySQL 연동 방법 MySQL 서버를 이미 설치하고 실행한 경우를 전제로 작업 진행 1. MySQL 패키지 설치 npm install mysql 2. MySQL 연결 생성 mysql 패키지를 import 후 연결을 설정할 객체와 연결 정보(호스트, 사용자, 비밀번호, 데이터베이스 이름 등) 입력하고, connect() 메소드를 사용하여 MySQL 서버에 연결 const mysql = require("mysql"); const connection = mysql.createConnection({ host: "localhost", user: "your_username", password: "your_password", database: "your_database", }); connection.connect((error) => {.. 2023. 8. 7. 이전 1 다음