![見出し画像](https://assets.st-note.com/production/uploads/images/151790085/rectangle_large_type_2_89e4d1a1a2fe48d0740772588781aa77.png?width=1200)
Ubuntu20にMariaDBをインストールする
MariaDB初期設定
最新バージョンのレポジトリをインストールする。
$ curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
$ sudo apt update
$ sudo apt install mariadb-server libmariadb-dev
動作確認
$ systemctl status mariadb
スタートアップで起動するように設定
$ systemctl enable mariadb
MariaDB初期設定
sudo mysql_secure_installation
下記のように回答
Enter current password for root (enter for none):
Switch to unix_socket authentication [Y/n] n
Change the root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
インストール確認
$ sudo mysql -v
ユーザー作成
MariaDB [(none)]> CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';
データベース作成
MariaDB [(none)]> CREATE DATABASE mydatabase;
権限付与
MariaDB [(none)]> GRANT all ON mydatabase.* TO 'myuser'@'localhost';