Ubuntu 21.10にMySQL8.0.27をインストールする
1.OSバージョンの確認
# cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=21.10 DISTRIB_CODENAME=impish DISTRIB_DESCRIPTION="Ubuntu 21.10"
2.インストール可能MySQLを確認します
# sudo apt info mysql-server Package: mysql-server Version: 8.0.27-0ubuntu0.21.10.1 Priority: optional Section: database Source: mysql-8.0 Origin: Ubuntu Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> Original-Maintainer: Debian MySQL Maintainers <pkg-mysql-maint@lists.alioth.debian.org> Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 110 kB Depends: mysql-server-8.0 Homepage: http://dev.mysql.com/ 略
3.MySQLをインストールする
# sudo apt install mysql-server
4.MySQLを起動します
# sudo service mysql start
自動起動を設定します
# sudo service mysql enable --now Usage: /etc/init.d/mysql start|stop|restart|reload|force-reload|status
ステータスの確認
# sudo service mysql status ● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset:> Active: active (running) since Sat 2021-11-27 02:03:53 PST; 15min ago
5.MySQL初期設定を行います
# mysql_secure_installation Securing the MySQL server deployment. Connecting to MySQL using a blank password. VALIDATE PASSWORD COMPONENT 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 component? ## パスワードを設定します 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 Please set the password for root here. ## rootのパスワードの設定 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. ## rootでのリモート接続はさせない 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. ## テストDBは不要 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!
6.MySQLに接続します
# mysql -u root -pArkgame9195@ mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 8.0.27-0ubuntu0.21.10.1 (Ubuntu) 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>
7.MySQLバージョンの確認
mysql> select version(); +-------------------------+ | version() | +-------------------------+ | 8.0.27-0ubuntu0.21.10.1 | +-------------------------+ 1 row in set (0.00 sec)