# MySQL किंवा MariaDB install करा

Source: https://ravindrabagale.com/mr/cyber/part-05/ch10-mysql-part-1-install-create-insert-and-select/10-1-installing-mysql-or-mariadb.html
Language: mr (Marathi with English technical terms)

MariaDB हा MySQL पासून वेगळा विकसित झालेला fork आहे. या course मधली basic SQL examples दोन्हीवर बहुतांश जुळतात; सर्व versions/features पूर्णपणे identical नाहीत. सामान्य database port 3306 आहे. Amazon Linux lab मध्ये MariaDB आणि Ubuntu lab मध्ये MySQL वापरू.

 | OS
 | Package
 | Service
 | Admin login

 | Amazon Linux 2023
 | mariadb105-server
 | mariadb
 | sudo mysql

 | Ubuntu 22.04/24.04
 | mysql-server (MySQL 8.x) or mariadb-server
 | mysql (or mariadb)
 | sudo mysql (root uses auth_socket)

 | CentOS Stream 9
 | mariadb-server (or mysql-server for MySQL 8)
 | mariadb (or mysqld)
 | sudo mysql

 | Amazon Linux 2 (older)
 | mariadb-server
 | mariadb
 | sudo mysql

Amazon Linux example

sudo yum install -y mariadb105-server
sudo service mariadb start
sudo systemctl enable mariadb
sudo service mariadb status

Ubuntu example

sudo apt update
sudo apt install -y mysql-server
sudo service mysql start
sudo systemctl enable mysql
sudo service mysql status

Package names/service names source मध्ये दिलेल्या releases चे examples आहेत. उपलब्ध supported version आणि repository तपासा. Database hardening prompts नीट वाचा: anonymous accounts, test DB आणि unnecessary remote admin login review करा.

sudo mysql_secure_installation      # remove anonymous users, test DB, remote root: answer Y
sudo mysql                          # log in as the admin (root) user

SQL prompt मध्ये version आणि databases पाहून EXIT करा. Root socket authentication configured असेल तर sudo mysql चालतो; existing setup मध्ये authentication वेगळं असू शकतं.

Database private ठेवा

या single-server lab मध्ये MySQL localhost/127.0.0.1 वरच listen करावा. sudo ss -tlnp | grep 3306 तपासा. Remote application architecture असल्यास private networking आणि निवडक sources वापरतात; database port सर्व internet साठी उघडू नका.

Practice

एका lab instance वर DB install/harden करा, योग्य local admin login वापरा आणि SELECT VERSION() output नोंदवा.

रवींद्र बागले यांची tip

Workbench साठी 3306 Anywhere उघडू नका. Authorized lab server साठी SSH tunnel: ssh -i key.pem -L 3307:127.0.0.1:3306 ec2-user@. Laptop वर Workbench ला 127.0.0.1:3307 द्या. Tunnel endpoint आणि DB credentials योग्य हवेत.
