단 10초 만에 PostgreSQL 및 MySQL 설정, 생성, 삭제 자동화
이것은DevOps분야의자동화 워크플로우로, 15개의 노드를 포함합니다.주로 If, Set, Ssh, ManualTrigger 등의 노드를 사용하며. Linux 서버에서 PostgreSQL 및 MySQL 데이터베이스 관리 자동화
- •특별한 사전 요구사항 없이 가져와 바로 사용 가능합니다
사용된 노드 (15)
카테고리
{
"id": "OnGUB1cHxzP09UTz",
"meta": {
"instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281",
"templateCredsSetupCompleted": true
},
"name": "Automate PostgreSQL & MySQL Setup, Creation & Deletion in Just 10 Seconds",
"tags": [],
"nodes": [
{
"id": "f024ece1-0378-4dbb-a1b7-06bf598a04de",
"name": "시작",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-760,
480
],
"parameters": {},
"typeVersion": 1
},
{
"id": "4bd36d6f-a312-4ff2-8b6f-86a6769f2588",
"name": "매개변수 설정",
"type": "n8n-nodes-base.set",
"position": [
-540,
480
],
"parameters": {
"values": {
"string": [
{
"name": "server_host",
"value": "={{ $json.server_host || '192.168.1.100' }}"
},
{
"name": "server_user",
"value": "{{ $json.server_user || 'root' }}"
},
{
"name": "server_password",
"value": "{{ $json.server_password || 'your_password' }}"
},
{
"name": "db_type",
"value": "={{ $json.db_type || 'postgresql' }}"
},
{
"name": "action",
"value": "={{ $json.action || 'install' }}"
},
{
"name": "database_name",
"value": "={{ $json.database_name || 'mydb' }}"
},
{
"name": "db_user",
"value": "{{ $json.db_user || 'dbuser' }}"
},
{
"name": "db_password",
"value": "{{ $json.db_password || 'dbpass123' }}"
}
]
},
"options": {}
},
"typeVersion": 1
},
{
"id": "8d23250e-4538-4b64-8fa4-a5cdabadc6ac",
"name": "데이터베이스 유형 확인",
"type": "n8n-nodes-base.if",
"position": [
-320,
480
],
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.db_type }}",
"value2": "postgresql"
}
]
}
},
"typeVersion": 1
},
{
"id": "f49751e8-cc9c-45bc-b677-c11919054be2",
"name": "PostgreSQL 작업 확인",
"type": "n8n-nodes-base.if",
"position": [
-100,
180
],
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.action }}",
"value2": "install"
}
]
}
},
"typeVersion": 1
},
{
"id": "bad68834-e9b1-406e-8a25-4a82d845b9eb",
"name": "MySQL 작업 확인",
"type": "n8n-nodes-base.if",
"position": [
-100,
780
],
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.action }}",
"value2": "install"
}
]
}
},
"typeVersion": 1
},
{
"id": "b4d41f1b-8d44-4725-87d6-72dd5d48d81a",
"name": "PostgreSQL 설치",
"type": "n8n-nodes-base.ssh",
"position": [
340,
-20
],
"parameters": {
"command": "#!/bin/bash\n\n# Install PostgreSQL\necho \"Installing PostgreSQL...\"\napt update -y\napt install -y postgresql postgresql-contrib\n\n# Start and enable PostgreSQL\nsystemctl start postgresql\nsystemctl enable postgresql\n\n# Configure PostgreSQL\nsudo -u postgres psql -c \"ALTER USER postgres PASSWORD '{{ $json.db_password }}';\"\n\n# Configure pg_hba.conf for password authentication\nsed -i \"s/#listen_addresses = 'localhost'/listen_addresses = '*'/g\" /etc/postgresql/*/main/postgresql.conf\necho \"host all all 0.0.0.0/0 md5\" >> /etc/postgresql/*/main/pg_hba.conf\n\n# Restart PostgreSQL\nsystemctl restart postgresql\n\n# Create database and user\nsudo -u postgres createdb {{ $json.database_name }}\nsudo -u postgres psql -c \"CREATE USER {{ $json.db_user }} WITH PASSWORD '{{ $json.db_password }}';\"\nsudo -u postgres psql -c \"GRANT ALL PRIVILEGES ON DATABASE {{ $json.database_name }} TO {{ $json.db_user }};\"\n\necho \"PostgreSQL installation and setup completed!\"\necho \"Database: {{ $json.database_name }}\"\necho \"User: {{ $json.db_user }}\"\necho \"Connection: psql -h {{ $json.server_host }} -U {{ $json.db_user }} -d {{ $json.database_name }}\"",
"authentication": "privateKey"
},
"credentials": {
"sshPrivateKey": {
"id": "ilPh8oO4GfSlc0Qy",
"name": "SSH Password account - test "
}
},
"typeVersion": 1
},
{
"id": "43acaf1f-beec-4d5d-9292-139626d04b05",
"name": "MySQL 설치",
"type": "n8n-nodes-base.ssh",
"position": [
340,
580
],
"parameters": {
"command": "#!/bin/bash\n\n# Install MySQL\necho \"Installing MySQL...\"\napt update -y\n\n# Set MySQL root password non-interactively\ndebconf-set-selections <<< \"mysql-server mysql-server/root_password password {{ $json.db_password }}\"\ndebconf-set-selections <<< \"mysql-server mysql-server/root_password_again password {{ $json.db_password }}\"\n\napt install -y mysql-server\n\n# Start and enable MySQL\nsystemctl start mysql\nsystemctl enable mysql\n\n# Configure MySQL for remote connections\nsed -i \"s/bind-address.*/bind-address = 0.0.0.0/g\" /etc/mysql/mysql.conf.d/mysqld.cnf\n\n# Restart MySQL\nsystemctl restart mysql\n\n# Create database and user\nmysql -u root -p{{ $json.db_password }} -e \"CREATE DATABASE {{ $json.database_name }};\"\nmysql -u root -p{{ $json.db_password }} -e \"CREATE USER '{{ $json.db_user }}'@'%' IDENTIFIED BY '{{ $json.db_password }}';\"\nmysql -u root -p{{ $json.db_password }} -e \"GRANT ALL PRIVILEGES ON {{ $json.database_name }}.* TO '{{ $json.db_user }}'@'%';\"\nmysql -u root -p{{ $json.db_password }} -e \"FLUSH PRIVILEGES;\"\n\necho \"MySQL installation and setup completed!\"\necho \"Database: {{ $json.database_name }}\"\necho \"User: {{ $json.db_user }}\"\necho \"Connection: mysql -h {{ $json.server_host }} -u {{ $json.db_user }} -p{{ $json.db_password }} {{ $json.database_name }}\"",
"authentication": "privateKey"
},
"credentials": {
"sshPrivateKey": {
"id": "ilPh8oO4GfSlc0Qy",
"name": "SSH Password account - test "
}
},
"typeVersion": 1
},
{
"id": "5315c681-2677-441b-8010-f7a742849b83",
"name": "PostgreSQL 생성 확인",
"type": "n8n-nodes-base.if",
"position": [
120,
280
],
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.action }}",
"value2": "create"
}
]
}
},
"typeVersion": 1
},
{
"id": "1fe28fb8-1dd9-488d-a7cf-bc47658d745e",
"name": "MySQL 생성 확인",
"type": "n8n-nodes-base.if",
"position": [
120,
880
],
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.action }}",
"value2": "create"
}
]
}
},
"typeVersion": 1
},
{
"id": "b65b1c99-ec5b-486c-8513-0b20ad54186e",
"name": "PostgreSQL DB 생성",
"type": "n8n-nodes-base.ssh",
"position": [
340,
180
],
"parameters": {
"command": "#!/bin/bash\n\n# Create PostgreSQL database\necho \"Creating PostgreSQL database: {{ $json.database_name }}\"\n\nsudo -u postgres createdb {{ $json.database_name }}\nsudo -u postgres psql -c \"CREATE USER {{ $json.db_user }} WITH PASSWORD '{{ $json.db_password }}';\"\nsudo -u postgres psql -c \"GRANT ALL PRIVILEGES ON DATABASE {{ $json.database_name }} TO {{ $json.db_user }};\"\n\necho \"PostgreSQL database created successfully!\"\necho \"Database: {{ $json.database_name }}\"\necho \"User: {{ $json.db_user }}\"",
"authentication": "privateKey"
},
"credentials": {
"sshPrivateKey": {
"id": "ilPh8oO4GfSlc0Qy",
"name": "SSH Password account - test "
}
},
"typeVersion": 1
},
{
"id": "aada1dd3-d236-4fe9-8ced-02d1ea20ef46",
"name": "MySQL DB 생성",
"type": "n8n-nodes-base.ssh",
"position": [
340,
780
],
"parameters": {
"command": "#!/bin/bash\n\n# Create MySQL database\necho \"Creating MySQL database: {{ $json.database_name }}\"\n\nmysql -u root -p{{ $json.db_password }} -e \"CREATE DATABASE {{ $json.database_name }};\"\nmysql -u root -p{{ $json.db_password }} -e \"CREATE USER '{{ $json.db_user }}'@'%' IDENTIFIED BY '{{ $json.db_password }}';\"\nmysql -u root -p{{ $json.db_password }} -e \"GRANT ALL PRIVILEGES ON {{ $json.database_name }}.* TO '{{ $json.db_user }}'@'%';\"\nmysql -u root -p{{ $json.db_password }} -e \"FLUSH PRIVILEGES;\"\n\necho \"MySQL database created successfully!\"\necho \"Database: {{ $json.database_name }}\"\necho \"User: {{ $json.db_user }}\"",
"authentication": "privateKey"
},
"credentials": {
"sshPrivateKey": {
"id": "ilPh8oO4GfSlc0Qy",
"name": "SSH Password account - test "
}
},
"typeVersion": 1
},
{
"id": "a77b9367-1eec-40c9-b636-9bd7535ecf7a",
"name": "PostgreSQL DB 삭제",
"type": "n8n-nodes-base.ssh",
"position": [
340,
380
],
"parameters": {
"command": "#!/bin/bash\n\n# Delete PostgreSQL database\necho \"Deleting PostgreSQL database: {{ $json.database_name }}\"\n\nsudo -u postgres dropdb {{ $json.database_name }}\nsudo -u postgres psql -c \"DROP USER IF EXISTS {{ $json.db_user }};\"\n\necho \"PostgreSQL database deleted successfully!\"\necho \"Database: {{ $json.database_name }} (deleted)\"\necho \"User: {{ $json.db_user }} (deleted)\"",
"authentication": "privateKey"
},
"credentials": {
"sshPrivateKey": {
"id": "ilPh8oO4GfSlc0Qy",
"name": "SSH Password account - test "
}
},
"typeVersion": 1
},
{
"id": "37b5c6e2-94f6-440f-b32d-6454e5178bfc",
"name": "MySQL DB 삭제",
"type": "n8n-nodes-base.ssh",
"position": [
340,
980
],
"parameters": {
"command": "#!/bin/bash\n\n# Delete MySQL database\necho \"Deleting MySQL database: {{ $json.database_name }}\"\n\nmysql -u root -p{{ $json.db_password }} -e \"DROP DATABASE IF EXISTS {{ $json.database_name }};\"\nmysql -u root -p{{ $json.db_password }} -e \"DROP USER IF EXISTS '{{ $json.db_user }}'@'%';\"\nmysql -u root -p{{ $json.db_password }} -e \"FLUSH PRIVILEGES;\"\n\necho \"MySQL database deleted successfully!\"\necho \"Database: {{ $json.database_name }} (deleted)\"\necho \"User: {{ $json.db_user }} (deleted)\"",
"authentication": "privateKey"
},
"credentials": {
"sshPrivateKey": {
"id": "ilPh8oO4GfSlc0Qy",
"name": "SSH Password account - test "
}
},
"typeVersion": 1
},
{
"id": "e23dbe7f-2bb3-4ba2-848a-e85688a05124",
"name": "출력 형식 지정",
"type": "n8n-nodes-base.set",
"position": [
560,
480
],
"parameters": {
"values": {
"string": [
{
"name": "result",
"value": "={{ $json.stdout }}"
},
{
"name": "status",
"value": "success"
},
{
"name": "action_performed",
"value": "={{ $('Set Parameters').item.json.action }}"
},
{
"name": "database_type",
"value": "={{ $('Set Parameters').item.json.db_type }}"
},
{
"name": "database_name",
"value": "={{ $('Set Parameters').item.json.database_name }}"
}
]
},
"options": {}
},
"typeVersion": 1
},
{
"id": "30cb203f-a298-41c9-b897-fc5c33178aa4",
"name": "메모",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1120,
-20
],
"parameters": {
"width": 620,
"height": 360,
"content": "## Core Elements\n- **Set Parameters** - Defines server details, database type, action, and credentials\n- **Type Check** - Confirms the selected database type\n- **PostgreSQL Action Check** - Identifies the action for PostgreSQL\n- **PostgreSQL Create Check** - Validates creation conditions for PostgreSQL\n- **Install PostgreSQL** - Sets up and configures PostgreSQL\n- **Create PostgreSQL DB** - Establishes a new PostgreSQL database with user access\n- **Delete PostgreSQL DB** - Removes a PostgreSQL database and user\n- **MySQL Action Check** - Identifies the action for MySQL\n- **MySQL Create Check** - Validates creation conditions for MySQL\n- **Install MySQL** - Sets up and configures MySQL\n- **Create MySQL DB** - Establishes a new MySQL database with user access\n- **Delete MySQL DB** - Removes a MySQL database and user\n- **Format Output** - Structures the final workflow output"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "a13a1931-c209-4f37-ab8c-bdc3c35b8fd4",
"connections": {
"f024ece1-0378-4dbb-a1b7-06bf598a04de": {
"main": [
[
{
"node": "4bd36d6f-a312-4ff2-8b6f-86a6769f2588",
"type": "main",
"index": 0
}
]
]
},
"43acaf1f-beec-4d5d-9292-139626d04b05": {
"main": [
[
{
"node": "e23dbe7f-2bb3-4ba2-848a-e85688a05124",
"type": "main",
"index": 0
}
]
]
},
"4bd36d6f-a312-4ff2-8b6f-86a6769f2588": {
"main": [
[
{
"node": "8d23250e-4538-4b64-8fa4-a5cdabadc6ac",
"type": "main",
"index": 0
}
]
]
},
"aada1dd3-d236-4fe9-8ced-02d1ea20ef46": {
"main": [
[
{
"node": "e23dbe7f-2bb3-4ba2-848a-e85688a05124",
"type": "main",
"index": 0
}
]
]
},
"37b5c6e2-94f6-440f-b32d-6454e5178bfc": {
"main": [
[
{
"node": "e23dbe7f-2bb3-4ba2-848a-e85688a05124",
"type": "main",
"index": 0
}
]
]
},
"b4d41f1b-8d44-4725-87d6-72dd5d48d81a": {
"main": [
[
{
"node": "e23dbe7f-2bb3-4ba2-848a-e85688a05124",
"type": "main",
"index": 0
}
]
]
},
"bad68834-e9b1-406e-8a25-4a82d845b9eb": {
"main": [
[
{
"node": "43acaf1f-beec-4d5d-9292-139626d04b05",
"type": "main",
"index": 0
}
],
[
{
"node": "1fe28fb8-1dd9-488d-a7cf-bc47658d745e",
"type": "main",
"index": 0
}
]
]
},
"1fe28fb8-1dd9-488d-a7cf-bc47658d745e": {
"main": [
[
{
"node": "aada1dd3-d236-4fe9-8ced-02d1ea20ef46",
"type": "main",
"index": 0
}
],
[
{
"node": "37b5c6e2-94f6-440f-b32d-6454e5178bfc",
"type": "main",
"index": 0
}
]
]
},
"8d23250e-4538-4b64-8fa4-a5cdabadc6ac": {
"main": [
[
{
"node": "f49751e8-cc9c-45bc-b677-c11919054be2",
"type": "main",
"index": 0
}
],
[
{
"node": "bad68834-e9b1-406e-8a25-4a82d845b9eb",
"type": "main",
"index": 0
}
]
]
},
"b65b1c99-ec5b-486c-8513-0b20ad54186e": {
"main": [
[
{
"node": "e23dbe7f-2bb3-4ba2-848a-e85688a05124",
"type": "main",
"index": 0
}
]
]
},
"a77b9367-1eec-40c9-b636-9bd7535ecf7a": {
"main": [
[
{
"node": "e23dbe7f-2bb3-4ba2-848a-e85688a05124",
"type": "main",
"index": 0
}
]
]
},
"f49751e8-cc9c-45bc-b677-c11919054be2": {
"main": [
[
{
"node": "b4d41f1b-8d44-4725-87d6-72dd5d48d81a",
"type": "main",
"index": 0
}
],
[
{
"node": "5315c681-2677-441b-8010-f7a742849b83",
"type": "main",
"index": 0
}
]
]
},
"5315c681-2677-441b-8010-f7a742849b83": {
"main": [
[
{
"node": "b65b1c99-ec5b-486c-8513-0b20ad54186e",
"type": "main",
"index": 0
}
],
[
{
"node": "a77b9367-1eec-40c9-b636-9bd7535ecf7a",
"type": "main",
"index": 0
}
]
]
}
}
}이 워크플로우를 어떻게 사용하나요?
위의 JSON 구성 코드를 복사하여 n8n 인스턴스에서 새 워크플로우를 생성하고 "JSON에서 가져오기"를 선택한 후, 구성을 붙여넣고 필요에 따라 인증 설정을 수정하세요.
이 워크플로우는 어떤 시나리오에 적합한가요?
중급 - 데브옵스
유료인가요?
이 워크플로우는 완전히 무료이며 직접 가져와 사용할 수 있습니다. 다만, 워크플로우에서 사용하는 타사 서비스(예: OpenAI API)는 사용자 직접 비용을 지불해야 할 수 있습니다.
관련 워크플로우 추천
Oneclick AI Squad
@oneclick-aiThe AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.
이 워크플로우 공유