MySQL 8.0をUbuntuにインストールしてみよう! リポジトリのインストールから解説する

Ubuntu18.04にMySQL 8.0をインストールします。UbuntuはCentOSよりも世界中でよく使われているので、今回はこれを選択しました。

$ wget
$ sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb


  • MySQL Server & Cluster ・・・ mysql-8.0
  • MySQL Preview Packages ・・・ 無効(Disabled)
  • MySQL Tools & Connectors ・・・ 有効(Enabled)


Configuring mysql-apt-config

MySQL APT Repo features MySQL Server along with a variety of MySQL components. You may select the appropriate product to choose
the version that you wish to receive.

Once you are satisfied with the configuration then select last option 'Ok' to save the configuration, then run 'apt-get update' to
load package list. Advanced users can always change the configurations later, depending on their own needs.

  1. MySQL Server & Cluster (Currently selected: mysql-8.0)  3. MySQL Preview Packages (Currently selected: Disabled)
  2. MySQL Tools & Connectors (Currently selected: Enabled)  4. Ok
Which MySQL product do you wish to configure? 4

Warning: apt-key should not be used in scripts (called from postinst maintainerscript of the package mysql-apt-config)
$ sudo apt install mysql-server mysql-client
$Configuring mysql-community-server

Please provide a strong password that will be set for the root account of your MySQL database. Leave it blank to enable password
less login using UNIX socket based authentication.

Enter root password: 

Now that you have selected a password for the root account, please confirm by typing it again. Do not share the password with

Re-enter root password: 

MySQL 8 uses a new authentication based on improved SHA256-based password methods. It is recommended that all new MySQL Server
installations use this method going forward. This new authentication plugin requires new versions of connectors and clients, with
support for this new authentication method (caching_sha2_password). Currently MySQL 8 Connectors and community drivers built with
libmysqlclient21 support this new method. Clients built with older versions of libmysqlclient may not be able to connect to the
new server.

To retain compatibility with older client software, the default authentication plugin can be set to the legacy value
(mysql_native_password) This should only be done if required third-party software has not been updated to work with the new
authentication method. The change will be written to the file /etc/mysql/mysql.conf.d/default-auth-override.cnf

After installation, the default can be changed by setting the default_authentication_plugin server setting.

  1. Use Strong Password Encryption (RECOMMENDED)  2. Use Legacy Authentication Method (Retain MySQL 5.x Compatibility)
Select default authentication plugin 1

update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Created symlink /etc/systemd/system/ → /lib/systemd/system/mysql.service.
$ sudo systemctl status mysql
sudo systemctl is-enabled mysql
sudo systemctl enable mysql
sudo systemctl stop mysql
sudo systemctl restart mysql