Cara Install Mysql Pada Ubuntu 18.04 LTS

Kalkulator Cetak
3 min readAug 8, 2018

--

Artikel ini akan membahas bagaimana cara melakukan installasi mysql pada ubuntu server 18.04 LTS. Langsung saja simak langkah-langkah dibawah ini. Langkah pertama lakukan update dan upgrade pada os yang digunakan menggunakan perintah dibawah ini

sudo apt-get updata sudo apt-get upgrade

Jika update dan upgrade sudah selesai maka lakukan reboot server, jalankan perintah berikut

reboot

Setelah reboot langkah selanjutnya melakukan installasi mysqlnya, jalankan perintah berikut

sudo apt-get install mysql-server

Kemudian cek status mysql apakah sudah berjalan atau belum

# service mysql status
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2018-08-07 09:00:18 UTC; 17h ago
Main PID: 3431 (mysqld)
Tasks: 29 (limit: 1110)
CGroup: /system.slice/mysql.service
└─3431 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid

Aug 07 09:00:17 rahmat systemd[1]: Starting MySQL Community Server...
Aug 07 09:00:18 rahmat systemd[1]: Started MySQL Community Server.

Agar lebih aman kita perlu melakukan setingan tambahan, jalankan perintah berikut

mysql_secure_installation

Kurang lebih outputnya seperti berikut ini

# mysql_secure_installation

Securing the MySQL server deployment.
Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No:
Please set the password for root here.

New password:
Re-enter new password:

By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) :

... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.

- Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done!

Jika sudah selesai bisa login ke mysql menggunakan perintah berikut ini

mysql -u root -p

Untuk melihat versi mysql yang digunakan bisa jalankan perintah berikut

mysqladmin -u root -p version

Outputnya seperti berikut

mysqladmin Ver 8.42 Distrib 5.7.23, for Linux on x86_64
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Server version 5.7.23-0ubuntu0.18.04.1
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/run/mysqld/mysqld.sock
Uptime: 16 hours 58 min 23 sec

Selanjutnya untuk membuat database dan username database, menggunakan perintah berikut,

CREATE DATABASE dbname;
USE dbname;
CREATE USER 'dbuser'@'localhost' IDENTIFIED BY 'password-dbuser';
GRANT ALL PRIVILEGES ON *.* TO 'dbuser'@'localhost';
FLUSH PRIVILEGES;

Nah mudah bukan, selamat mencoba ya semoga berhasil 😛

Originally published at https://rahmat.web.id on August 8, 2018.

--

--

No responses yet