> For the complete documentation index, see [llms.txt](https://saveyourtime.gitbook.io/saveyourtime/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://saveyourtime.gitbook.io/saveyourtime/backend/install-mysql-on-ubuntu.md).

# Install MySQL on Ubuntu

#### Download

```
wget https://dev.mysql.com/get/mysql-apt-config_0.8.16-1_all.deb
```

#### Install

```
sudo dpkg -i mysql-apt-config_0.8.16-1_all.deb
```

```
sudo apt-get update
```

```
sudo apt-get install mysql-server
```

#### Check MySQL status

```
systemctl status mysql
```

#### Create a user

```
CREATE USER 'my_username'@'%' IDENTIFIED BY 'my_password';
```

{% hint style="info" %}
To create a user that can connect from any host, use the `'%'` wildcard as a host part.
{% endhint %}

#### Grand all privileges to a user account on all databases

```
GRANT ALL PRIVILEGES ON *.* TO 'my_username'@'%';
```

#### 重新載入權限表：

```
FLUSH PRIVILEGES;
```

{% embed url="<https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/>" %}

{% embed url="<https://dev.mysql.com/downloads/repo/apt/>" %}
