Install MySQL Server on Ubuntu 22.04

Install MySQL Server pada Ubuntu 22.04

  • Update repository index
root@ubuntu-2204:~# apt update
  • Cek versi mysql pada repository, secara default akan terinstall versi 8.0
root@ubuntu-2204:~# apt info mysql-server
Package: mysql-server
Version: 8.0.28-0ubuntu4
Priority: optional
Section: database
Source: mysql-8.0
Origin: Ubuntu
  • Install MySQL Server pada ubuntu 22.04
root@ubuntu-2204:~# apt install mysql-server mysql-client -y
  • mysql secure installation
root@ubuntu-2204:~# mysql_secure_installation

Press y|Y for Yes, any other key for No: N
Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
  • Enable service mysql
root@ubuntu-2204:~# systemctl enable --now mysql
root@ubuntu-2204:~# systemctl status mysql
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-04-27 05:31:19 UTC; 2min 53s ago
   Main PID: 1582 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 2327)
     Memory: 358.6M
        CPU: 1.614s
     CGroup: /system.slice/mysql.service
             └─1582 /usr/sbin/mysqld
  • Cek versi mysql server
root@ubuntu-2004:~# mysql -V
mysql  Ver 8.0.28-0ubuntu4 for Linux on x86_64 ((Ubuntu))

root@ubuntu-2204:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.28-0ubuntu4 (Ubuntu)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select version();
| version()       |
| 8.0.28-0ubuntu4 |
1 row in set (0.00 sec)

mysql> show databases;
| Database           |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
4 rows in set (0.01 sec)


A system administrator with skills in system administration, virtualization, linux, windows, networking, cloud computing, container, etc.