How to Install MySQL on Ubuntu - Step-by-Step Guide

Опубликовано: 07 Март 2025
на канале: SkillSharp
3,599
37

Welcome to our tutorial on installing MySQL on Ubuntu! Follow these simple steps to set up MySQL on your Ubuntu system and start managing databases effortlessly.

Points Covered:

Update Ubuntu:

Open a terminal and type: sudo apt update
Install MySQL Server:

In the terminal, enter: sudo apt install mysql-server
Login to MySQL:

Open the terminal and type: sudo mysql
Update Root Password for MySQL:

Inside the MySQL terminal, execute:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_new_password';
EXIT;

MySQL Secure Installation:

Run the command: mysql_secure_installation
Login to Secure MySQL:

Open the terminal and type: mysql -u root -p
Create a Sample Database:

Inside the MySQL terminal, run:
CREATE DATABASE exampleDB;
SHOW DATABASES;

Create a New MySQL User:

Inside the MySQL terminal, execute:
CREATE USER 'user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

Switch to MySQL Database:

Inside the MySQL terminal, run:
USE mysql;
SELECT user FROM user;

Grant Access to User for Sample DB:

Inside the MySQL terminal, run:
GRANT ALL ON exampleDB.* TO 'user'@'localhost';

Conclusion:
Now you're all set! Enjoy using MySQL on your Ubuntu system. If you found this tutorial helpful, don't forget to like, share, and subscribe for more tech tutorials. Thanks for watching!