標籤:指南 command nodeps 成功 now() use man 否則 fail
環境說明:
作業系統:Red Hat Linux 6
安裝Mysql5.7版本
安裝須知:
一、準備mysql的安裝包
二、準備好安裝環境
操作指導:
一、下載mysql的安裝包
https://www.mysql.com/downloads/ 訪問mysql,進行如下操作進行下載。
將下載好的mysql安裝包放到自己建立的安裝目錄下,進行解壓。
[[email protected] /]# cd /soft/[[email protected] soft]# ll總用量 1151432-rw-r--r--. 1 root root 227512320 8月 7 17:59 MySQL-5.6.41-1.el6.x86_64.rpm-bundle.tar-rw-r--r--. 1 root root 475770880 8月 7 18:21 mysql-5.7.23-1.el6.x86_64.rpm-bundle.tar-rw-r--r--. 1 7155 31415 24024136 6月 11 11:21 mysql-community-client-5.7.23-1.el6.x86_64.rpm-rw-r--r--. 1 7155 31415 340072 6月 11 11:21 mysql-community-common-5.7.23-1.el6.x86_64.rpm-rw-r--r--. 1 7155 31415 3736628 6月 11 11:21 mysql-community-devel-5.7.23-1.el6.x86_64.rpm-rw-r--r--. 1 7155 31415 39496088 6月 11 11:21 mysql-community-embedded-5.7.23-1.el6.x86_64.rpm-rw-r--r--. 1 7155 31415 137638820 6月 11 11:21 mysql-community-embedded-devel-5.7.23-1.el6.x86_64.rpm-rw-r--r--. 1 7155 31415 2192692 6月 11 11:21 mysql-community-libs-5.7.23-1.el6.x86_64.rpm-rw-r--r--. 1 7155 31415 1723712 6月 11 11:21 mysql-community-libs-compat-5.7.23-1.el6.x86_64.rpm-rw-r--r--. 1 7155 31415 160480880 6月 11 11:21 mysql-community-server-5.7.23-1.el6.x86_64.rpm-rw-r--r--. 1 7155 31415 106124936 6月 11 11:21 mysql-community-test-5.7.23-1.el6.x86_64.rpm
二、準備好安裝環境
檢查當前系統下是否有mysql服務,方法: rpm -qa | grep mysql。 如果有就用rpm卸載掉。可以使用的命令是 rpm -ev 程式(如果卸載報存在依賴關係問題就用,rpm -e --nodeps 程式 進行卸載, --nodeps 跳過依賴關係)
[[email protected] mysql]# rpm -qa | grep mysqlmysql-libs-5.1.71-1.el6.x86_64[email protected] mysql]# rpm -ev mysql-libs-5.1.71-1.el6.x86_64 /*報依賴關係*/error: Failed dependencies: libmysqlclient.so.16()(64bit) is needed by (installed) postfix-2:2.6.6-2.2.el6_1.x86_64 libmysqlclient.so.16(libmysqlclient_16)(64bit) is needed by (installed) postfix-2:2.6.6-2.2.el6_1.x86_64[[email protected] soft]# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64 /*卸載不含依賴關係*/[[email protected] soft]#
三、進行mysql服務安裝
進入到mysql包的解壓目錄下,用rpm進行安裝。注意安裝順序,否則或報依賴關係錯誤。
[[email protected] soft]# rpm -ivh mysql-community-common-5.7.23-1.el6.x86_64.rpm[[email protected] soft]# rpm -ivh mysql-community-libs-5.7.23-1.el6.x86_64.rpm[[email protected] soft]# rpm -ivh mysql-community-client-5.7.23-1.el6.x86_64.rpm[[email protected] soft]# rpm -ivh mysql-community-server-5.7.23-1.el6.x86_64.rpm
安裝完成,修改設定檔。在/etc/my.cnf
[[email protected] etc]# vim my.cnf[mysqld]skip-grant-tables /*添加,作用可以不用密碼進行登入*/
啟動mysql服務,輸入mysql就可以進入資料庫。(啟用成功可以用 netstat -nlap | grep mysql 查看mysql服務)
[[email protected] soft]# service mysqld start[[email protected] soft]# mysql Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 23Server version: 5.7.23 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 itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql>
這時,你可以使用navicat工具串連mysql服務了。如果串連不上,請檢查3306連接埠是否開發,可以嘗試關閉linux防火牆。service iptables stop
嘗試串連成功後,我們可以為mysql服務設定密碼。
先選擇使用者
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> update user set authentication_string = password(‘111111‘), password_expired = ‘N‘, password_last_changed = now() where user = ‘root‘;Query OK, 1 row affected, 1 warning (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 1mysql> flush privileges; /*刷入配置,必須執行,否則後期錯誤資訊*/Query OK, 0 rows affected (0.00 sec)mysql>
註:這個設定密碼方式如果不對,可以嘗試其它方法設定密碼(如:mysqladmin -u root password “11111111”)。設定完密碼切記要去my.cnf設定檔把skip-grant-tables 注釋掉,在重啟mysql服務。這是就可使用使用者名稱密碼登入。
navicat使用指南:http://www.formysql.com/mysql/jiqiao/
Mysql資料庫安裝使用過程