&
Operating System(オペレーティング・システム)」を選択します。
この表示は mysql-8.0.21-linux-glibc2.12-x86_64.tar.xz です。
サーバーにアップロード、MD5チェック
[root@localhost home]# md5sum mysql-8.0.21-linux-glibc2.12-x86_64.tar.xz
d39efe001766edfa956e673c1a60a26a mysql-8.0.21-linux-glibc2.12-x86_64.tar.xz
エラーがないことを確認したら、インストールを続行できます。この検証は、MySQL がオープンソースであり、インストールするために誰かがパッケージを流出させた可能性があるためです。
MySQL 5.7
公式のインストール手順は dev.mysql.com/doc/refman/...
まず、/homeディレクトリにパッケージを置き、次のようにします。
[root@localhost home]# groupadd mysql
[root@localhost home]# useradd -r -g mysql mysql
[root@localhost home]# cd /usr/local/
[root@localhost local]# tar zxvf /home/mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
[root@localhost local]# ln -s mysql-5.7.25-linux-glibc2.12-x86_64/ mysql
[root@localhost local]# cd mysql
[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .
[root@localhost mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data
2020-07-24T10:50:24.570102Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-07-24T10:50:26.546019Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-07-24T10:50:26.712657Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-07-24T10:50:26.773747Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 7bbb9509-cd9b-11ea-bc39-000c29c4f2c8.
2020-07-24T10:50:26.776911Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-07-24T10:50:26.778037Z 1 [Note] A temporary password is generated for root@localhost: *eok
[root@localhost mysql]# mkdir data
[root@localhost mysql]# bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data
Generating a 2048 bit RSA private key
...........................+++
...............................+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
................+++
..........+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
.....................................+++
....+++
writing new private key to 'client-key.pem'
-----
設定ファイルの変更
[root@localhost mysql]# vim /etc/myf
設定ファイルの内容を変更すると、全文は次のようになります。
[mysqld]
basedir=/usr/local/mysql
datadir=/data
ソフトリンクの起動と追加
[root@localhost bin]# cd /usr/local/mysql/support-files/
[root@localhost support-files]# cp mysql.server /etc/init.d/mysql
[root@localhost mysql]# ln -s /usr/local/mysql/bin/mysql /usr/bin
ログインとパスワードの変更、ここではパスワードは初期化ログによって生成されます *eok
[root@localhost bin]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.25
(c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
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> set password=password('root');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> grant all privileges on *.* to 'root'@'%' identified by 'root';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> quit;
Bye
- information_schema 情報アーキテクチャ
- mysql ユーザログイン情報
- performance_schema パフォーマンス監視
- sys MySQL 5.7 では、performance_schema 配下の複雑なテーブルを整理する新しいライブラリが追加されました。
ブートローダのセットアップ
[root@localhost bin]# cd /usr/local/mysql/support-files/
[root@localhost support-files]# vim /etc/profile
# 最初に
export PATH==/usr/local/mysql/bin:$PATH
[root@localhost support-files]# source /etc/profile
[root@localhost support-files]# cd /etc/init.d/
[root@localhost init.d]# chkconfig --add mysql
[root@localhost init.d]# chkconfig --level 345 mysql on
MySQLステータス関連
[root@localhost ~]# service mysql status
SUCCESS! MySQL running (2742)
[root@localhost ~]# service mysql stop
Shutting down MySQL.. SUCCESS!
[root@localhost ~]# service mysql start
Starting MySQL. SUCCESS!
リモートアクセスファイアウォール
[root@localhost ~]# firewall-cmd --state
running
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
設定ファイル関連
1、サーバー内無料ログイン
[root@localhost ~]# vim /etc/myf
[client]
# 安全なログイン
user=root
password=root
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.25 MySQL Community Server (GPL)
(c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
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>
2、ライブラリにあるユーザーの操作を表示します。
[root@localhost ~]# vim /etc/myf
# ヒントタブ
[mysql]
prompt=(\\u@\\h)[\\d]>\\_
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.25 MySQL Community Server (GPL)
(c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
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.
(root@localhost)[(none)]>
3.アンインストール
# MySQLを閉じる
# インストール中に作成されたファイルを削除する datadir=/data
MySQL 5.6
公式のインストール手順は dev.mysql.com/doc/refman/...
インストール手順
[root@localhost home]# groupadd mysql
[root@localhost home]# useradd -r -g mysql mysql
[root@localhost home]# cd /usr/local/
[root@localhost local]# tar zxvf /home/mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz
[root@localhost local]# ln -s mysql-5.6.43-linux-glibc2.12-x86_64/ mysql
[root@localhost local]# cd mysql
[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .
# 設定ファイルを5.7メインの
[root@localhost mysql]# vim /etc/myf
# usr/local/mysql/myf を削除する。
[root@localhost mysql]# rm -rf myf
[root@localhost mysql]# scripts/mysql_install_db --user=mysql
# パスワードは設定ファイルにある
[root@localhost mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.43 MySQL Community Server (GPL)
(c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
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.
(root@localhost)[(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
(root@localhost)[(none)]> quit;
Bye
#開始し、ソフトリンクを追加する
[root@localhost bin]# cd /usr/local/mysql/support-files/
[root@localhost support-files]# cp mysql.server /etc/init.d/mysql
[root@localhost mysql]# ln -s /usr/local/mysql/bin/mysql /usr/bin
#ブートローダのセットアップ
[root@localhost bin]# cd /usr/local/mysql/support-files/
[root@localhost support-files]# vim /etc/profile
# 最初に
export PATH==/usr/local/mysql/bin:$PATH
[root@localhost support-files]# source /etc/profile
[root@localhost support-files]# cd /etc/init.d/
[root@localhost init.d]# chkconfig --add mysql
[root@localhost init.d]# chkconfig --level 345 mysql on
5.6 インストール時に起こりうる問題
[root@localhost mysql]# scripts/mysql_install_db --user=mysql
FATAL ERROR: please install the following Perl modules before executing scripts/mysql_install_db:
Data::Dumper
# autoconfがない
[root@localhost mysql]# yum -y install autoconf
MySQL 8.0
公式のインストール手順は dev.mysql.com/doc/refman/...
5.7のインストールとほぼ同じ手順です。
この記事に関係する構成パラメータ
[client]
# 安全なログイン
user=root
password=root
# ヒントタブ
[mysql]
prompt=(\\u@\\h)[\\d]>\\_
[mysqld]
basedir=/usr/local/mysql
datadir=/data





