-
Notifications
You must be signed in to change notification settings - Fork 6
nodejs mysql aws ec2 aws rds
egoing edited this page Nov 18, 2021
·
10 revisions
- github.com 가입
- git : https://git-scm.com/
- visual studio code : https://code.visualstudio.com/
-
git initsimple.js
var http = require('http');
var app = http.createServer(function(request,response){
response.end(`
<h1><a href="index.html">WEB</a></h1>
<ul>
<li><a href="html.html">html</a></li>
<li><a href="nodejs.html">nodejs</a></li>
<li><a href="mysql.html">mysql</a></li>
</ul>
<h2>Welcome</h2>
Hello WEB!!
`);
});
app.listen(80);git add simple.js && git commit -m "simple.js"
git push -u origin master
- os : ubuntu 20
- instance type : micro
- security group : 22, 80, 3000 port 개방
- key-pair를 생성하고 다운로드 받습니다.
- ssh -i KEY_PAIR_NAME.pem ubuntu@PUBLIC_IP_ADDRESS
ssh-keygen-
cat ~/.ssh/id.rsa.pub로 파일의 내용을 복사해서 github.com > settings > SSH 에 등록합니다. -
git clone RPOSITORY_URL .저장소를 복제합니다.
- sudo apt update && sudo apt install -y nodejs
sudo node simple.js
- 생성방식 : 손쉬운 생성
- 구성 : MySQL
- 인스턴스 크기 : 프리티어
- 마스터 사용자 이름 : admin
- 마스터 암호 : 111111
- db 인스턴스의 VPC 보안그룹을 클릭합니다.
- 인바운드 편집을 선택합니다.
- 유형에 MySQL을 선택합니다. 소스에 EC2의 보안그룹의 이름을 입력합니다.
- sudo apt update && sudo apt install mysql-client -y
- mysql -hHOST_NAME -uadmin -p
--
-- Table structure for table `author`
--
CREATE TABLE `author` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
`profile` varchar(200) DEFAULT NULL,
PRIMARY KEY (`id`)
);
--
-- Dumping data for table `author`
--
INSERT INTO `author` VALUES (1,'egoing','developer');
INSERT INTO `author` VALUES (2,'duru','database administrator');
INSERT INTO `author` VALUES (3,'taeho','data scientist, developer');
--
-- Table structure for table `topic`
--
CREATE TABLE `topic` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(30) NOT NULL,
`description` text,
`created` datetime NOT NULL,
`author_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
);
--
-- Dumping data for table `topic`
--
INSERT INTO `topic` VALUES (1,'MySQL','MySQL is...','2018-01-01 12:10:11',1);
INSERT INTO `topic` VALUES (2,'Oracle','Oracle is ...','2018-01-03 13:01:10',1);
INSERT INTO `topic` VALUES (3,'SQL Server','SQL Server is ...','2018-01-20 11:01:10',2);
INSERT INTO `topic` VALUES (4,'PostgreSQL','PostgreSQL is ...','2018-01-23 01:03:03',3);
INSERT INTO `topic` VALUES (5,'MongoDB','MongoDB is ...','2018-01-30 12:31:03',1);- ALTER USER 'USER_ID'@'%' IDENTIFIED WITH mysql_native_password BY 'PASSWORD'; 참고 : https://kogle.tistory.com/87
- sudo apt update && sudo apt install npm -y
- git clone https://github.com/web-n/node.js-mysql.git
- cd node.js-mysql
- cd lib
- cp db.template.js db.js
- nano db.js
- host, user, password, database를 변경합니다.
- cd ..
- npm install 로 의존성을 설치합니다.
node main.js
http://PUBLIC_DNS_URL:3000