Tudásbázis

How to Install and Secure MySQL on Ubuntu

MySQL is a popular relational database. This guide installs it and runs the security hardening script.

1. Install MySQL Server

sudo apt update
sudo apt install -y mysql-server

2. Run the security script

sudo mysql_secure_installation

This lets you set a root password and remove insecure defaults (anonymous users, test database, remote root login). Answer Yes to the hardening prompts.

3. Create a database and user

sudo mysql

CREATE DATABASE myapp;
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON myapp.* TO 'myuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

4. Connect

mysql -u myuser -p myapp

Always use a strong, unique password and grant each application user only the privileges it needs.

Hasznosnak találta ezt a választ?

0 A felhasználók hasznosnak találták ezt

Powered by WHMCompleteSolution