Ubuntu20.04にMySQL8.0をインストールする方法

Ubuntu/Debian

目次

MySQLは、構造化データをテーブル形式で格納するために使用される一般的なリレーショナルデータベース管理システムです。 これはオープンソースのデータベースサーバーであり、SQL(Structured Query Language)ステートメントを使用して対話します。 MySQLは、GNU General PublicLicenseの条件の下で無料で利用できます。

このチュートリアルは、MySQL8をUbuntu20.04 LTS FocalLinuxシステムにインストールするのに役立ちます。

前提条件

sudo特権アカウントアクセスを備えたUbuntu20.04LTSシステムが実行されている必要があります。 次に、システムにログインしてターミナルを開きます。

ssh [email protected] 

以下のコマンドを実行して、現在のパッケージを最新バージョンにアップグレードします。

sudo apt update && sudo apt upgrade 

ステップ1-MySQLPPAを有効にする

MySQLチームは、Ubuntuオペレーティングシステム用の公式MySQLPPAを提供しています。 パッケージをダウンロードしてUbuntu18.04システムにインストールすると、PPAファイルがシステムに追加されます。 以下のコマンドを実行して、PPAを有効にします。

wget http://repo.mysql.com/mysql-apt-config_0.8.10-1_all.deb  sudo dpkg -i mysql-apt-config_0.8.10-1_all.deb 

インストーラーは、MySQLバージョンのデフォルトリポジトリを設定するように要求します。 MySQL-8が現在選択されている状態に設定されていることを確認してください。 これを変更するには、行に移動してEnterキーを押します。

mysqlはapt構成を変更します

適切なバージョンが選択されたら、キーボードの上下キーを使用して、カーソルを最後の行「OK」に移動します。 Enterキーを押して、プロセスを続行します。

間違ったバージョンを選択した場合。 実行する dpkg-reconfigure mysql-apt-config パッケージのインストール後にコマンドを実行して、このウィンドウを再度取得します。

ステップ2–UbuntuへのMySQL8のインストール

システムはMySQLインストールの準備ができています。 以下のコマンドに従って、Ubuntu 20.04LinuxシステムにMySQL8をインストールします。

  1. GPGキーの追加– 次のコマンドを実行して、MySQLをUbuntu18.04システムにインストールします。
    sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 8C718D3B5072E1F5 
  2. キャッシュの更新– 以下のコマンドを実行して、システムのaptキャッシュを更新します。
    sudo apt update  
  3. MySQLのインストール– 最後に、MySQLサーバーパッケージをインストールします。
    sudo apt install mysql-server 

インストールプロセスでは、rootパスワードをデフォルトとして設定するように求められます。 安全なパスワードを入力し、パスワードウィンドウを確認します。 これは、MySQLサーバーにログインするために必要なMySQLrootユーザーのパスワードになります。

Ubuntu18.04上のMySQL

Ubuntu18.04上のMySQL

ステップ3–MySQLの安全なインストール

システムで以下のコマンドを実行して、データベースサーバーのセキュリティを変更します。 これはいくつかの質問を促します。 高いセキュリティはすべての答えを提供しますか はい

sudo mysql_secure_installation 

ここでは、パスワード検証プラグインを有効/無効にし、パスワードに必要な強度を設定し、匿名ユーザーを削除し、rootログインをリモートで禁止し、テストデータベースとアクセスを削除し、変更を適用した後にリロード権限を再読み込みできます。

以下の出力と私が取ったアクションを参照してください。

Securing the MySQL server deployment.

Enter password for user root:

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: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root.

Estimated strength of the password: 50
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password: ****************

Re-enter new password: ****************

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
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) : y
Success.

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!

ステップ4–MySQLに接続する

MySQLサーバーがシステムにインストールされています。 次に、コマンドラインを使用してMySQLデータベースに接続します。 上記の手順で設定したrootアカウントのパスワードを使用します。

 mysql -u root -p  Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 9 Server version: 8.0.23 MySQL Community Server - GPL Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql>

結論

このチュートリアルを完了すると、Ubuntu 20.04LinuxシステムにMySQL8がインストールされます。 ターミナルからMySQLにアクセスできる場合でも、phpMyAdminをインストールして操作することもできます。

実稼働ユーザーは、データベースのバックアップを定期的にスケジュールすることを推奨しました。 このスクリプトは、MySQLデータベースのバックアップをスケジュールし、それらをリモートの場所にコピーするのに役立ちます。

Hope this helps!

Source link

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です