# Connection MySQL with Docker and WSL on Windows

<figure><img src="https://3397141630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVUQUm1GVUT3pDnRHmDRU%2Fuploads%2FVgTTHONy0L7sbSQP0CJF%2Fimage.png?alt=media&#x26;token=40a0012a-47dd-4418-9a61-fac8c07cbcc2" alt=""><figcaption></figcaption></figure>

Docker itu apa ?

Docker ini bisa dibilang pengganti XAMPP, hanya saja di XAMPP kita ga perlu setting-setting lagi udah bersih tinggal pakai, nah kalau di Docker ini kita bisa tambahakan container pada satu sistem, misal kita bisa pakai mysql, postgresql, dll

Caranya seperti ini:

1\. Install WSL (pengguna Windows)

Cari **Turn Windows Features on or off**\
Select **Hyper-V** and **click OK**

<figure><img src="https://3397141630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVUQUm1GVUT3pDnRHmDRU%2Fuploads%2F1OoBkShIxJo96VyfqPEa%2Fimage.png?alt=media&#x26;token=a5dd0691-7244-4e50-8645-e02136f4d403" alt=""><figcaption></figcaption></figure>

2\. Install Docker

aktifkan go to Bios => configuration => **Virtualization technology** => enable it.

3\. Buka WSL lalu copycat code berikut

<pre><code><strong>docker run -d --name mysqldb -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql:latest
</strong></code></pre>

#### Jika ada error seperti ini:

<figure><img src="https://3397141630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVUQUm1GVUT3pDnRHmDRU%2Fuploads%2F1GU3K5QCed8HP9rcPXyD%2Fimage.png?alt=media&#x26;token=bfba5a5d-ee95-4285-857e-167c8d9fc56d" alt=""><figcaption></figcaption></figure>

Jalankan command ini

```
sudo mkdir -p /etc/docker
```

```
sudo nano /etc/docker/daemon.json
```

Copy paste code berikut, lalu save

```
{
  "dns": ["8.8.8.8", "8.8.4.4"]
}
```

```
sudo systemctl restart docker
```

4\. Install DBeaver

Disini untuk Interface database kalian bebas menggunakan apa, hanya disini saya kasih contoh dengan DBeaver

* Buat koneksi baru dengan MySQL
* Connection settings -> SSL
* uncheck "Verify server certificate"
* check "Allow public key retrival"

<figure><img src="https://3397141630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVUQUm1GVUT3pDnRHmDRU%2Fuploads%2F2uaMsR88MCRE9lOMmH6K%2Fimage.png?alt=media&#x26;token=20dc3d4f-405d-45cd-92c8-8c21afe51e70" alt=""><figcaption></figcaption></figure>

Selesai

Baca juga: [*Koneksi PostgreSQL ke GUI DBeaver di Windows*](https://rysxa.gitbook.io/s/coding/docker/koneksi-postgresql-ke-gui-dbeaver-di-windows)

Gomawo^
