Centos 7インストールMysql 8


1.mysql 8の公式ソースに参加する
yum localinstall https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
yum clean all
yum makecache

2.mysql 8のインストール
yum install mysql-community-server

3.mysqlを起動する
systemctl start mysqld.service

3.1一時パスワードの取得
[root@localhost mysql]# grep "A temporary password" /var/log/mysqld.log
2018-12-15T16:08:17.317445Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: -te-.s9yVqW;

3.2 rootパスワードを変更するには、大文字と小文字の特殊文字を含める必要があります.
[root@localhost mysql]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.13

Copyright (c) 2000, 2018, 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> alter user 'root'@'localhost' identified by 'Luca321@';
Query OK, 0 rows affected (0.06 sec)

 
4.起動解決失敗
[root@localhost lib]# systemctl start mysqld.service  Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service"and "journalctl -xe"for details.
 
4.1サービスステータスを確認し、問題は示さなかった.
[root@localhost lib]# systemctl status mysqld.service ● mysqld.service - MySQL Server    Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)    Active: failed (Result: exit-code) since Sat 2018-12-15 10:59:58 EST; 2min 37s ago      Docs: man:mysqld(8)            http://dev.mysql.com/doc/refman/en/using-systemd.html   Process: 18496 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)   Process: 18472 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)  Main PID: 18496 (code=exited, status=1/FAILURE)    Status: "SERVER_BOOTING"    Error: 2 (No such file or directory)
Dec 15 10:59:58 localhost.localdomain systemd[1]: Starting MySQL Server... Dec 15 10:59:58 localhost.localdomain systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE Dec 15 10:59:58 localhost.localdomain systemd[1]: Failed to start MySQL Server. Dec 15 10:59:58 localhost.localdomain systemd[1]: Unit mysqld.service entered failed state. Dec 15 10:59:58 localhost.localdomain systemd[1]: mysqld.service failed.
● mysqld.service - MySQL Server    Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)    Active: failed (Result: exit-code) since Sat 2018-12-15 10:59:58 EST; 2min 37s ago      Docs: man:mysqld(8)            http://dev.mysql.com/doc/refman/en/using-systemd.html   Process: 18496 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS (code=exited, status=1/FAILURE)   Process: 18472 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)  Main PID: 18496 (code=exited, status=1/FAILURE)    Status: "SERVER_BOOTING"    Error: 2 (No such file or directory)
Dec 15 10:59:58 localhost.localdomain systemd[1]: Starting MySQL Server... Dec 15 10:59:58 localhost.localdomain systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE Dec 15 10:59:58 localhost.localdomain systemd[1]: Failed to start MySQL Server. Dec 15 10:59:58 localhost.localdomain systemd[1]: Unit mysqld.service entered failed state. Dec 15 10:59:58 localhost.localdomain systemd[1]: mysqld.service failed.
[root@localhost lib]# journalctl -xe Dec 15 10:59:58 localhost.localdomain polkitd[751]: Registered Authentication Agent for unix-process:18466:834528 (system bus name :1.29 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path/org/freede Dec 15 10:59:58 localhost.localdomain systemd[1]: Starting MySQL Server... -- Subject: Unit mysqld.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel --  -- Unit mysqld.service has begun starting up. Dec 15 10:59:58 localhost.localdomain systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE Dec 15 10:59:58 localhost.localdomain systemd[1]: Failed to start MySQL Server. -- Subject: Unit mysqld.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel --  -- Unit mysqld.service has failed. --  -- The result is failed. Dec 15 10:59:58 localhost.localdomain systemd[1]: Unit mysqld.service entered failed state. Dec 15 10:59:58 localhost.localdomain systemd[1]: mysqld.service failed. Dec 15 10:59:58 localhost.localdomain polkitd[751]: Unregistered Authentication Agent for unix-process:18466:834528 (system bus name :1.29, object path/org/freedesktop/PolicyKit1/AuthenticationAgent, locale  Dec 15 11:01:01 localhost.localdomain systemd[1]: Started Session 4 of user root. -- Subject: Unit session-4.scope has finished start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel --  -- Unit session-4.scope has finished starting up. --  -- The start-up result is done. Dec 15 11:01:01 localhost.localdomain systemd[1]: Starting Session 4 of user root. -- Subject: Unit session-4.scope has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel --  -- Unit session-4.scope has begun starting up. Dec 15 11:01:01 localhost.localdomain CROND[18503]: (root) CMD (run-parts/etc/cron.hourly) Dec 15 11:01:01 localhost.localdomain run-parts(/etc/cron.hourly)[18506]: starting 0anacron Dec 15 11:01:01 localhost.localdomain run-parts(/etc/cron.hourly)[18512]: finished 0anacron Dec 15 11:02:22 localhost.localdomain dbus-daemon[745]: dbus[745]: avc:  received setenforce notice (enforcing=0) Dec 15 11:02:22 localhost.localdomain dbus[745]: avc:  received setenforce notice (enforcing=0) Dec 15 11:02:39 localhost.localdomain polkitd[751]: Registered Authentication Agent for unix-process:18518:850668 (system bus name :1.32 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path/org/freede Dec 15 11:02:39 localhost.localdomain systemd[1]: Starting MySQL Server... -- Subject: Unit mysqld.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel --  -- Unit mysqld.service has begun starting up. Dec 15 11:02:40 localhost.localdomain systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE Dec 15 11:02:40 localhost.localdomain systemd[1]: Failed to start MySQL Server. -- Subject: Unit mysqld.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel --  -- Unit mysqld.service has failed. --  -- The result is failed. Dec 15 11:02:40 localhost.localdomain systemd[1]: Unit mysqld.service entered failed state. Dec 15 11:02:40 localhost.localdomain systemd[1]: mysqld.service failed. Dec 15 11:02:40 localhost.localdomain polkitd[751]: Unregistered Authentication Agent for unix-process:18518:850668 (system bus name :1.32, object path/org/freedesktop/PolicyKit1/AuthenticationAgent, locale   
4.2 mysqlログしか表示できません.ここでは明らかに/var/lib/mysql/問題があります.
[root@localhost lib]# tail -f/var/log/mysqld.log  2018-12-15T16:05:45.384297Z 0 [System] [MY-013169] [Server]/usr/sbin/mysqld (mysqld 8.0.13) initializing of server in progress as process 18584 2018-12-15T16:05:45.386729Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting. 2018-12-15T16:05:45.386788Z 0 [ERROR] [MY-013236] [Server] Newly created data directory/var/lib/mysql/is unusable. You can safely remove it. 2018-12-15T16:05:45.386797Z 0 [ERROR] [MY-010119] [Server] Aborting 2018-12-15T16:05:45.387015Z 0 [System] [MY-010910] [Server]/usr/sbin/mysqld: Shutdown complete (mysqld 8.0.13)  MySQL Community Server - GPL. 2018-12-15T16:05:45.645437Z 0 [System] [MY-010116] [Server]/usr/sbin/mysqld (mysqld 8.0.13) starting as process 18586 2018-12-15T16:05:45.656019Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory. 2018-12-15T16:05:45.656216Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed. 2018-12-15T16:05:45.656258Z 0 [ERROR] [MY-010119] [Server] Aborting 2018-12-15T16:05:45.656981Z 0 [System] [MY-010910] [Server]/usr/sbin/mysqld: Shutdown complete (mysqld 8.0.13)  MySQL Community Server - GPL.
 
4.3ディレクトリに入ってデータを削除する
[root@localhost lib]# cd/var/lib/mysql [root@localhost mysql]# ll total 48 -rw-r-----. 1 mysql mysql     0 Dec 15 09:27 binlog.index -rw-------. 1 mysql mysql  1675 Dec 15 09:27 ca-key.pem -rw-r--r--. 1 mysql mysql  1107 Dec 15 09:27 ca.pem -rw-r--r--. 1 mysql mysql  1107 Dec 15 09:27 client-cert.pem -rw-------. 1 mysql mysql  1679 Dec 15 09:27 client-key.pem drwx------. 2 mysql mysql 16384 Dec 15 08:36 lost+found -rw-------. 1 mysql mysql  1679 Dec 15 09:27 private_key.pem -rw-r--r--. 1 mysql mysql   451 Dec 15 09:27 public_key.pem -rw-r--r--. 1 mysql mysql  1107 Dec 15 09:27 server-cert.pem -rw-------. 1 mysql mysql  1679 Dec 15 09:27 server-key.pem [root@localhost mysql]# rm -rf *
 
4.5起動を試み、問題を解決する
[root@localhost ~]# systemctl start mysqld.service   [root@localhost ~]# netstat -tanlp Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name     tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1363/sshd            tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      18310/master         tcp        0     96 10.205.127.71:22        10.205.57.106:50295     ESTABLISHED 10519/sshd: root@pt  tcp6       0      0:::3306                :::*                    LISTEN      18676/mysqld         tcp6       0      0:::22                  :::*                    LISTEN      1363/sshd            tcp6       0      0::1:25                  :::*                    LISTEN      18310/master         tcp6       0      0:::33060                :::*                    LISTEN      18676/mysqld