標籤:inpu where linux版本 sel http sha bundle cte 尋找
目錄
[TOC]
1、查看當前安裝的Linux版本
[[email protected] ~]$ sudo lsb_release -aLSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarchDistributor ID: CentOSDescription: CentOS release 6.9 (Final)Release: 6.9Codename: Final
2、下載MySQL 安裝檔案
官方網站 http://www.mysql.com
直接下載 https://downloads.mysql.com/archives/get/file/mysql-5.7.19-1.el6.x86_64.rpm-bundle.tar。
3、清理老版本MySQL3.1、查看作業系統中是否已安裝MySQL
[[email protected] ~]$ sudo rpm -qa | grep mysqlmysql-5.1.73-8.el6_8.x86_64mysql-server-5.1.73-8.el6_8.x86_64mysql-libs-5.1.73-8.el6_8.x86_64
3.2、刪除老版本MySQL資料庫安裝包
[[email protected] ~]$ sudo rpm -e --nodeps mysql-5.1.73-8.el6_8.x86_64[[email protected] ~]$ sudo rpm -e --nodeps mysql-server-5.1.73-8.el6_8.x86_64[[email protected] ~]$ sudo rpm -e --nodeps mysql-libs-5.1.73-8.el6_8.x86_64
3.3、尋找老版本MySQL安裝遺留的目錄和檔案
[[email protected] ~]$ find / -name mysql/var/lib/mysql
3.4、刪除老版本MySQL安裝遺留的目錄和檔案
[[email protected] ~]$ sudo rm -rf /var/lib/mysql
4、安裝新版本MySQL4.1、解包
[[email protected] softs]$ tar -xvf mysql-5.7.19-1.el6.x86_64.rpm-bundle.tar mysql-community-libs-5.7.19-1.el6.x86_64.rpmmysql-community-devel-5.7.19-1.el6.x86_64.rpmmysql-community-embedded-5.7.19-1.el6.x86_64.rpmmysql-community-common-5.7.19-1.el6.x86_64.rpmmysql-community-libs-compat-5.7.19-1.el6.x86_64.rpmmysql-community-server-5.7.19-1.el6.x86_64.rpmmysql-community-test-5.7.19-1.el6.x86_64.rpmmysql-community-embedded-devel-5.7.19-1.el6.x86_64.rpmmysql-community-client-5.7.19-1.el6.x86_64.rpm
4.2、安裝MySQL
[[email protected] softs]$ sudo rpm -ivh mysql-community-common-5.7.19-1.el6.x86_64.rpmwarning: mysql-community-common-5.7.19-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... ########################################### [100%] 1:mysql-community-common ########################################### [100%][[email protected] softs]$ sudo rpm -ivh mysql-community-libs-5.7.19-1.el6.x86_64.rpmwarning: mysql-community-libs-5.7.19-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... ########################################### [100%] 1:mysql-community-libs ########################################### [100%][[email protected] softs]$ sudo rpm -ivh mysql-community-client-5.7.19-1.el6.x86_64.rpmwarning: mysql-community-client-5.7.19-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... ########################################### [100%] 1:mysql-community-client ########################################### [100%][[email protected] softs]$ sudo rpm -ivh mysql-community-server-5.7.19-1.el6.x86_64.rpmwarning: mysql-community-server-5.7.19-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEYPreparing... ########################################### [100%] 1:mysql-community-server ########################################### [100%]
4.3、啟動MySQL資料庫
[[email protected] ~]$ sudo service mysqld startInitializing MySQL database: [ OK ]Starting mysqld: [ OK ][[email protected] ~]$ sudo mysqld_safe --user=mysql --skip-grant-tables --skip-networking &[1] 3598[[email protected] ~]$ 2017-11-15T01:58:49.095993Z mysqld_safe Logging to ‘/var/log/mysqld.log‘.2017-11-15T01:58:49.129531Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql[[email protected] ~]$ mysql -u root mysqlReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -AWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 4Server version: 5.7.19 MySQL Community Server (GPL)Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> update user set authentication_string = password(‘root123‘) where user = ‘root‘;Query OK, 1 row affected, 1 warning (0.01 sec)Rows matched: 1 Changed: 1 Warnings: 1mysql> flush privileges;Query OK, 0 rows affected (0.01 sec)mysql> quitBye[[email protected] ~]$ sudo service mysqld restartStopping mysqld: [ OK ]Starting mysqld: [ OK ][[email protected] ~]$ mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 5Server version: 5.7.19Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> show databases;ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.mysql> set password for [email protected] = password(‘)OKM9ijn‘); Query OK, 0 rows affected, 1 warning (0.01 sec)mysql> flush privileges;Query OK, 0 rows affected (0.02 sec)mysql> quitBye
4、遠程登入4.1、授權
[[email protected] ~]$ mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 22Server version: 5.7.19 MySQL Community Server (GPL)Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> select host, user from user;+-----------+---------------+| host | user |+-----------+---------------+| localhost | mysql.session || localhost | mysql.sys || localhost | root |+-----------+---------------+3 rows in set (0.00 sec)mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘)OKM9ijn‘ WITH GRANT OPTION; Query OK, 0 rows affected, 1 warning (0.02 sec)mysql> select host, user from user;+-----------+---------------+| host | user |+-----------+---------------+| % | root || localhost | mysql.session || localhost | mysql.sys || localhost | root |+-----------+---------------+4 rows in set (0.00 sec)mysql> FLUSH PRIVILEGES;Query OK, 0 rows affected (0.07 sec)
4.2、測試
在其他機器上測試
C:\>mysql -h 192.168.1.144 -u root -pEnter password: ********Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 23Server version: 5.7.19 MySQL Community Server (GPL)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
CentOS 6.9下MySQL5.7.19安裝步驟