CentOS 8 Mysql 8をインストールし、POSTを設定

5814 ワード

0.mysqlはyumのインストールを提供しているように見えます.
yum install mysql-server

後ろの時間がないので見なくてもいいです.
まずwgetをインストールします
yum -y install wget
1.rpmインストールファイルのダウンロード
wget http://repo.mysql.com/mysql-community-release-el7.rpm
2.rpm取付の実行
rpm -ivh mysql-community-release-el7.rpm
依存解析が完了すると、次のオプションが表示されます.
 1 Dependencies Resolved
 2 
 3 ================================================================================================================================================================
 4  Package                                                  Arch                 Version                  Repository                          Size
 5 ================================================================================================================================================================
 6 Installing:
 7  mysql-community-libs                                    x86_64              5.6.32-2.el7             mysql56-community                    2.0 M
 8  replacing  mariadb-libs.x86_64 1:5.5.47-1.el7_2
 9  mysql-community-server                                  x86_64              5.6.32-2.el7             mysql56-community                     59 M
10  Installing for dependencies:
11  mysql-community-client                                  x86_64              5.6.32-2.el7             mysql56-community                     19 M
12  mysql-community-common                                  x86_64              5.6.32-2.el7             mysql56-community                    256 k
13  perl-Compress-Raw-Bzip2                                 x86_64              2.061-3.el7              base                                  32 k
14  perl-Compress-Raw-Zlib                                  x86_64              1:2.061-4.el7            base                                  57 k
15  perl-DBI                                                x86_64              1.627-4.el7              base                                 802 k
16  perl-IO-Compress                                        noarch              2.061-2.el7              base                                 260 k
17  perl-Net-Daemon                                         noarch              0.48-5.el7               base                                  51 k
18  perl-PlRPC                                              noarch              0.2020-14.el7            base                                  36 k
19 
20 Transaction Summary
21 ================================================================================================================================================================
22 Install  2 Packages (+8 Dependent packages)
23 
24 Total download size: 82 M
25 Is this ok [y/d/N]: 

3.serverとclientがインストールされていることがわかります.yを選択し、インストールを自動的にダウンロードします.
4.インストールが完了したら、Mysqlを起動します.
systemctl start  mysqld.service
きどうモード
1、サービスで起動:サービスmysqld start
2、mysqldスクリプトを使用して起動する:/etc/inint.d/mysqld start
 
二、停止
1、サービスで起動:サービスmysqld stop
2、mysqldスクリプトを使用して起動する:/etc/inint.d/mysqld stop
 
三、再起動
1、サービスで起動:サービスmysqld restart
2、mysqldスクリプトを使用して起動する:/etc/inint.d/mysqld restart
ログインmysql:mysql-u root-p
5.rootパスワードを設定します.ALTER USER 'root'@'localhost' IDENTIFIED BY ' ';(mysqlデータベースに切り替えるにはuse mysqlを使用することに注意)
/*update user set password=password("123456") where user='root';*/
6.起動してから起動する.
1 vim /etc/rc.local
2   service mysqld start

Mysqlサービスの開始
      systemctl start mysqld
 
起動の設定
       systemctl enable mysqld
       systemctl daemon-reload
 
7.重要な更新:
新しいrpmインストールファイルには自動yumインストールのスクリプトがありません.手動でyumインストールを実行する必要があります.
すなわち、ステップ2の後にyum install mysql-serverを実行すればよい.
8.自己起動について
ステップ6はmysqldが自己起動していない条件下でのみ適用される.
デフォルトmysqlが自己起動の場合、rc.localの自己起動で乱順などの問題が発生しました.
より穏当な解決策を見てみましょう.
CentOS 7プログラムの自己起動の問題
http://www.cnblogs.com/yoyotl/p/6194321.html

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '  ' WITH GRANT OPTION;

その後、変更を更新し、FLUSH PRIVILEGES;
 
1:linuxログインmysql
[root@localhost mysql]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.13 MySQL Community Server - GPL

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> 


2:userテーブルを表示し、接続レベルを変更する
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> select host,user from user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| localhost | root             |
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
+-----------+------------------+
4 rows in set (0.00 sec)

rootユーザーのhost値はlocalhostです.これはローカル接続のみを表し、localhostを%に変更します.
update user set host='%' where user='root';

3:ここまでで終わりだと思うかもしれませんが、navicat接続テストを使用すると、ホスト名に関するエラーを解析できないことがヒントになります.これはmysql 8のセキュリティポリシーの問題です.具体的には左に曲がってgoogle、解決方法は以下の通りです.
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'yourpassword';