浅いCentOS 6.8インストールMySQL 8.0.18チュートリアル(RPM方式)
今日、CentOS 6.8サーバにMySQL 8.0.18をインストールする方法を記録しました。無駄話は多くなく、直接にテーマに入ります。
一、CentOSをアンインストールします。6.8自分のMySQL
まず、CentOS 6.8サーバに内蔵されているMySQLをアンインストールし、コマンドラインに以下のコマンドを入力してCentOS 6.8サーバが所有するMySQLを確認する。
二、MySQLの設置依存環境
正式にMySQLをインストールする前に、まずMySQLの依存ベース環境をインストールする必要があります。
コマンドラインでは、次のコマンドを実行して、mysqlユーザを追加します。
まず、CentOS 6.8サーバのコマンドラインで、MySQL 8.0.18のRPMインストールパケットをダウンロードするコマンドを実行します。
まず、
五、初期化MySQLデータ
まず、MySQLの公式はMySQLの運行に制限があります。
MySQL 8.xでは、初期化データは、データベースディレクトリとファイルの所有者がmysqlアカウントに登録されていることを確認する必要があります。rootとしてmysqldサービスを実行するなら、以下のように「userオプション」を含む命令を実行することを確認する必要があります。
rootユーザとしてCentOS 6.8サーバにログインすると、以下のコマンドが実行されます。
六、MySQLを起動する
CentOS 6.8サーバコマンドラインに以下のコマンドを入力して、MySQLサービスを開始します。
七、MySQL登録
MySQLには、仮パスワードで登録してください。
次に、再びMySQLコマンドラインでSQL文を実行します。
八、rpmでMySQLをインストールするデフォルトのディレクトリ
1、データベースディレクトリ
MySQL 8.0デフォルトではmy.cnfがありません。手動でmy.cnfファイルを作成できます。以下のようにMySQLディレクトリを指定するコマンド初期化データです。
以上は小编でご绍介したCentOS 6.8にMySQL 8.0.18のチュートリアル(RPM方式)をインストールし、皆様のご协力をお愿いします。もし何かご质问がありましたら、メッセージをください。小编はすぐにご返事します。ここでも私たちのサイトを応援してくれてありがとうございます。本文があなたのためになると思ったら、転載を歓迎します。出所を明記してください。ありがとうございます。
一、CentOSをアンインストールします。6.8自分のMySQL
まず、CentOS 6.8サーバに内蔵されているMySQLをアンインストールし、コマンドラインに以下のコマンドを入力してCentOS 6.8サーバが所有するMySQLを確認する。
[root@binghe151 src]# rpm -qa | grep -i mysql
mysql-libs-5.1.73-7.el6.x86_64
CentOS 6.8サーバには、デフォルトでmysql-libs-51.73-7.el 6.6 x 86_がインストールされていると見られます。64,次はmysql-libs-51.73-7 el 6.6 x 86_64をアンインストールします。以下のようにします。
[root@binghe151 src]# rpm -e mysql-libs-5.1.73-7.el6.x86_64 --nodeps
[root@binghe151 src]#
CentOS 6.8サーバが持つMySQLを再度確認します。以下の通りです。
[root@binghe151 src]# rpm -qa | grep -i mysql
[root@binghe151 src]#
CentOS 6.8サーバが持っているMySQLのアンインストールに成功したと説明します。二、MySQLの設置依存環境
正式にMySQLをインストールする前に、まずMySQLの依存ベース環境をインストールする必要があります。
yum -y install wget gcc-c++ ncurses ncurses-devel cmake make perl bison openssl openssl-devel gcc* libxml2 libxml2-devel curl-devel libjpeg* libpng* freetype* make gcc-c++ cmake bison-devel ncurses-devel bison perl perl-devel perl perl-devel net-tools* numactl*
三、mysqlユーザーを追加するコマンドラインでは、次のコマンドを実行して、mysqlユーザを追加します。
groupadd mysql
useradd -g mysql mysql
四、MySQLのRPMインストールパッケージをダウンロードしてインストールするまず、CentOS 6.8サーバのコマンドラインで、MySQL 8.0.18のRPMインストールパケットをダウンロードするコマンドを実行します。
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.18-1.el6.x86_64.rpm-bundle.tar
次に、ダウンロードしたMySQL 8.0.18のRPMインストールパッケージを確認します。
[root@binghe151 src]# ll
total 744876
-rw-r--r--. 1 root root 762746880 Nov 18 14:32 mysql-8.0.18-1.el6.x86_64.rpm-bundle.tar
次に、ダウンロードしたインストールパッケージを解凍します。
[root@binghe151 src]# tar xvf mysql-8.0.18-1.el6.x86_64.rpm-bundle.tar
mysql-community-client-8.0.18-1.el6.x86_64.rpm
mysql-community-test-8.0.18-1.el6.x86_64.rpm
mysql-community-server-8.0.18-1.el6.x86_64.rpm
mysql-community-libs-compat-8.0.18-1.el6.x86_64.rpm
mysql-community-common-8.0.18-1.el6.x86_64.rpm
mysql-community-devel-8.0.18-1.el6.x86_64.rpm
mysql-community-libs-8.0.18-1.el6.x86_64.rpm
次に、順番に取り付けます。
mysql-community-common-8.0.18-1.el6.x86_64.rpm
mysql-community-libs-8.0.18-1.el6.x86_64.rpm
mysql-community-client-8.0.18-1.el6.x86_64.rpm
mysql-community-server-8.0.18-1.el6.x86_64.rpm
取り付けには、上記の手順に従って厳密に取り付ける必要があります。まず、
mysql-community-common-8.0.18-1.el6.x86_64.rpm
をインストールします。次のようにします。
[root@binghe151 src]# rpm -ivh mysql-community-common-8.0.18-1.el6.x86_64.rpm
warning: mysql-community-common-8.0.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-common ########################################### [100%]
次に、mysql-communnity-libs-8.8-1.el 6.6 x 86_をインストールします。64.rpmを下記に示します。
[root@binghe151 src]# rpm -ivh mysql-community-libs-8.0.18-1.el6.x86_64.rpm
warning: mysql-community-libs-8.0.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-libs ########################################### [100%]
次に、mysql-community-client-8.0.18-1.el6.x86_64.rpm
を取り付けます。以下のようにします。
[root@binghe151 src]# rpm -ivh mysql-community-client-8.0.18-1.el6.x86_64.rpm
warning: mysql-community-client-8.0.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-client ########################################### [100%]
最後に、mysql-communnity-server-80.0.18-1.el 6.6 x 86_をインストールします。64.rpmを下記に示します。
[root@binghe151 src]# rpm -ivh mysql-community-server-8.0.18-1.el6.x86_64.rpm
warning: mysql-community-server-8.0.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:mysql-community-server ########################################### [100%]
mysql-communnity-server-8.1.el 6.x 86_64. rpmの時にエラーが発生しました。次のようになります。
[root@binghe151 src]# rpm -ivh mysql-community-server-8.0.18-1.el6.x86_64.rpm
warning: mysql-community-server-8.0.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
libnuma.so.1()(64bit) is needed by mysql-community-server-8.0.18-1.el6.x86_64
libnuma.so.1(libnuma_1.1)(64bit) is needed by mysql-community-server-8.0.18-1.el6.x86_64
libnuma.so.1(libnuma_1.2)(64bit) is needed by mysql-community-server-8.0.18-1.el6.x86_64
libnumaライブラリが不足しています。次のコマンドを実行してlibnumaをインストールします。yum install numactl* -y
コマンド実行後、再度mysql-communnity-server-8.1.el 6.6_をインストールします。64.rpmでいいです。五、初期化MySQLデータ
まず、MySQLの公式はMySQLの運行に制限があります。
MySQL 8.xでは、初期化データは、データベースディレクトリとファイルの所有者がmysqlアカウントに登録されていることを確認する必要があります。rootとしてmysqldサービスを実行するなら、以下のように「userオプション」を含む命令を実行することを確認する必要があります。
shell> bin/mysqld --initialize --user=mysql
shell> bin/mysqld --initialize-insecure --user=mysql
mysqlのアカウントでプログラムを登録して実行する場合は、--userオプションをコマンドから削除してもいいです。
shell> bin/mysqld --initialize
shell> bin/mysqld --initialize-insecure
以上のMySQL公式のMySQLの運行に対する制限により、導出できます。rootユーザとしてCentOS 6.8サーバにログインすると、以下のコマンドが実行されます。
mysqld --initialize --user=mysql
mysqld --initialize-insecure --user=mysql
CentOS 6.8サーバにmysqlユーザとして登録すれば、以下のコマンドが実行されます。
mysqld --initialize
mysqld --initialize-insecure
ここではrootアカウントを使ってCentOS 6.8サーバにログインしていますので、データベースを初期化する時には、下記のコマンドを実行します。
mkdir -p /usr/local/mysql
chown -R mysql.mysql /usr/local/mysql
mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
注意:ここで、私はmysqld--initializeコマンドを実行する時、MySQLのインストールディレクトリを指定しました。MySQLのインストール中、MySQLのインストールディレクトリを指定することを推奨します。dataディレクトリがusr/local/mysqlディレクトリに存在すると初期化に失敗します。/usr/local/mysqlの下にdataディレクトリがないことを確認しなければなりません。六、MySQLを起動する
CentOS 6.8サーバコマンドラインに以下のコマンドを入力して、MySQLサービスを開始します。
[root@binghe151 src]# service mysqld start
Starting mysqld:
[ OK ]
MySQLを起動すると、MySQLのrootアカウントに仮登録パスワードを生成します。このパスワードは/var/log/mysqld.logファイルで確認できます。vimエディタを使って/var/log/mysqld.logファイルを開きます。
vim /var/log/mysqld.log
2019-11-18T08:16:08.162464Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.18) initializing of server in progress as process 2111
2019-11-18T08:16:12.451542Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: -8cagKkdK#5G
2019-11-18T08:17:13.269505Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18) starting as process 2378
2019-11-18T08:17:16.568836Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2019-11-18T08:17:16.642494Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.18' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server - GPL.
2019-11-18T08:17:16.652000Z 7 [Warning] [MY-013360] [Server] Plugin sha256_password reported: ''sha256_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instea
d'
2019-11-18T08:17:16.801986Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
次の行のコードが見つかりました。
2019-11-18T08:16:12.451542Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: -8cagKkdK#5G
MySQLを起動する際に生成される仮登録パスワードは、-8 cagKdK〓を参照してください。七、MySQL登録
MySQLには、仮パスワードで登録してください。
[root@binghe151 src]# mysql -uroot -p-8cagKkdK#5G
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 9
Server version: 8.0.18
Copyright (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>
このとき、MySQLコマンドラインでSQL文のエラーが発生し、パスワードのリセットが要求されます。
mysql> SHOW DATABASES;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql>
次に、MySQLのrootアカウントのパスワードを変更します。
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
Query OK, 0 rows affected (0.03 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
次に、MySQLコマンドラインでexitコマンドを入力してMySQLを終了します。修正したrootパスワードを使ってMySQLに再登録します。
mysql> exit
Bye
[root@binghe151 src]# mysql -uroot -proot
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.18 MySQL Community Server - GPL
Copyright (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>
MySQLのrootアカウントのパスワードが変更されました。次に、再びMySQLコマンドラインでSQL文を実行します。
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.36 sec)
mysql> USE mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>
MySQLのrootアカウントのパスワードを変更すると、MySQL命令行でSQL文を正しく実行することができます。八、rpmでMySQLをインストールするデフォルトのディレクトリ
1、データベースディレクトリ
/var/lib/mysql/
2、プロファイル/usr/share/mysql(mysql.server )
3、関連命令/usr/bin(mysqladmin mysqldump )
4、起動スクリプト/etc/rc.d/init.d/( mysql )
九、my.cnfファイルの配置MySQL 8.0デフォルトではmy.cnfがありません。手動でmy.cnfファイルを作成できます。以下のようにMySQLディレクトリを指定するコマンド初期化データです。
mkdir -p /usr/local/mysql
chown -R mysql.mysql /usr/local/mysql
mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
my.cnf 。
[client]
port = 3306
# mysql.sock
socket = /tmp/mysql.sock
[mysqld]
#Mysql mysql Id
server-id = 1
# 3306
port = 3306
#mysql
basedir = /usr/local/mysql
#mysql
datadir = /usr/local/mysql/data
#pid
pid-file = /usr/local/mysql/mysql.pid
# socke
socket = /tmp/mysql.sock
#
tmpdir = /tmp
#
user = mysql
# IP
bind-address = 0.0.0.0
#
#skip-grant-tables
# MyISAM ,
skip-external-locking
# IP ,
skip_name_resolve = 1
# , ,mysql ( , )
transaction_isolation = READ-COMMITTED
# , ( 4 )
character-set-server = utf8mb4
# , character-set-server
collation-server = utf8mb4_general_ci
# client mysql ,
init_connect='SET NAMES utf8mb4'
# sql ,1
lower_case_table_names = 1
#
max_connections = 400
#
max_connect_errors = 1000
#TIMESTAMP NOT NULL, NULL
explicit_defaults_for_timestamp = true
#SQL , BLOB 1G
max_allowed_packet = 128M
#MySQL ( : )
#MySQL wait_timeout 8 , interactive_timeout
interactive_timeout = 1800
wait_timeout = 1800
# , 128M。
# group by ,order by ,
# , IO
tmp_table_size = 134217728
max_heap_table_size = 134217728
# mysql
#
#
query_cache_size = 0
query_cache_type = 0
#
log_error = error.log
# sql
slow_query_log = 1
slow_query_log_file = slow.log
# sql
log_queries_not_using_indexes = 1
# log_queries_not_using_indexes , sql 、
log_throttle_queries_not_using_indexes = 5
# , sql
log_slow_slave_statements = 1
# ,
long_query_time = 8
#
min_examined_row_limit = 100
#mysql binlog ,
expire_logs_days = 5
締め括りをつける以上は小编でご绍介したCentOS 6.8にMySQL 8.0.18のチュートリアル(RPM方式)をインストールし、皆様のご协力をお愿いします。もし何かご质问がありましたら、メッセージをください。小编はすぐにご返事します。ここでも私たちのサイトを応援してくれてありがとうございます。本文があなたのためになると思ったら、転載を歓迎します。出所を明記してください。ありがとうございます。