您好,登錄后才能下訂單哦!
Mysql一個(gè)熟悉的概念,一個(gè)全新的知識(shí)領(lǐng)域。開始我全方位數(shù)據(jù)庫(kù)學(xué)習(xí)之旅。
一切,從安裝開始,自己動(dòng)手每一步。
Linux在安裝的過程中,可以勾選Mysql的安裝,但是安裝的版本是Mysql-5.1.73,版本非常低。必須重新安裝,當(dāng)前最新版本是5.7。但是卸載再安裝,明顯比空白Linux安裝麻煩一點(diǎn)。
下面開始卸載/安裝過程。
1. Mysql下載地址
mysql-5.7.22-1.el6.x86_64.rpm-bundle.tar https://dev.mysql.com/downloads/file/?id=476884
2. 確認(rèn)OS版本
# more /etc/issue CentOS release 6.7 (Final) Kernel \r on an \m
# lsb_release -a LSB 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-noarch Distributor ID: CentOS Description: CentOS release 6.7 (Final) Release: 6.7 Codename: Final
3. 根據(jù)OS版本,找到需要下載的Mysql版本,右鍵“將鏈接另存為”,即可獲得下載地址
4. 到Linux下,通過wget下載
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.18-1.el6.x86_64.rpm
下面三個(gè)rpm包存在依賴關(guān)系,也需要下載
# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-common-5.7.18-1.el6.x86_64.rpm # wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-client-5.7.18-1.el6.x86_64.rpm # wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-libs-5.7.18-1.el6.x86_64.rpm
5. 檢查查詢發(fā)現(xiàn),已經(jīng)安裝Mysql-5.1.73,版本非常低。必須重新安裝,當(dāng)前最新版本是5.7
# rpm -qa | grep mysql mysql-server-5.1.73-5.el6_6.x86_64 mysql-libs-5.1.73-5.el6_6.x86_64 mysql-5.1.73-5.el6_6.x86_64 mysql-connector-odbc-5.1.5r1144-7.el6.x86_64
6. 準(zhǔn)備安裝,安裝前,就懷疑,會(huì)不會(huì)覆蓋?會(huì)不會(huì)沖突?安裝一下試試,就知道了。
同時(shí)安裝4個(gè)rpm包
# rpm -ivh mysql-community-server-5.7.18-1.el6.x86_64.rpm mysql-community-client-5.7.18-1.el6.x86_64.rpm mysql-community-common-5.7.18-1.el6.x86_64.rpm mysql-community-libs-5.7.18-1.el6.x86_64.rpm
7. 果然沖突了
warning: mysql-community-server-5.7.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ########################################### [100%] file /usr/share/mysql/czech/errmsg.sys from install of mysql-community-common-5.7.18-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64 file /usr/share/mysql/danish/errmsg.sys from install of mysql-community-common-5.7.18-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64 file /usr/share/mysql/dutch/errmsg.sys from install of mysql-community-common-5.7.18-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64 file /usr/share/mysql/english/errmsg.sys from install of mysql-community-common-5.7.18-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64 file /usr/share/mysql/estonian/errmsg.sys from install of mysql-community-common-5.7.18-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.73-5.el6_6.x86_64 ......
8. 經(jīng)過查詢,也安裝失敗了,還是5.1.73版本
# rpm -qa|grep mysql mysql-server-5.1.73-5.el6_6.x86_64 mysql-libs-5.1.73-5.el6_6.x86_64 mysql-5.1.73-5.el6_6.x86_64 mysql-connector-odbc-5.1.5r1144-7.el6.x86_64
9. 開始卸載原有的5.1.73的Mysql,幾種卸載方式,首推YUM方式卸載
# yum remove mysql # rpm -e mysql // 普通刪除模式 # rpm -e --nodeps mysql // 強(qiáng)力刪除模式,如果使用上面命令刪除時(shí),提示有依賴的其它文件,則用該命令可以對(duì)其進(jìn)行強(qiáng)力刪除
10 .還剩余下面兩個(gè)包
# rpm -qa|grep mysql mysql-libs-5.1.73-5.el6_6.x86_64 mysql-connector-odbc-5.1.5r1144-7.el6.x86_64
11. 執(zhí)行yum localinstall安裝,發(fā)現(xiàn)需要卸載mysql-libs-5.1.73-5.el6_6.x86_64,通過yun卸載這個(gè)包后,可以安裝了。
# yum localinstall mysql-community-server-5.7.18-1.el6.x86_64.rpm mysql-community-client-5.7.18-1.el6.x86_64.rpm mysql-community-common-5.7.18-1.el6.x86_64.rpm mysql-community-libs-5.7.18- 1.el6.x86_64.rpm ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Local Package Process Examining mysql-community-server-5.7.18-1.el6.x86_64.rpm: mysql-community-server-5.7.18-1.el6.x86_64 Marking mysql-community-server-5.7.18-1.el6.x86_64.rpm to be installed Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.cn99.com * updates: mirrors.163.com Examining mysql-community-client-5.7.18-1.el6.x86_64.rpm: mysql-community-client-5.7.18-1.el6.x86_64 Marking mysql-community-client-5.7.18-1.el6.x86_64.rpm to be installed Examining mysql-community-common-5.7.18-1.el6.x86_64.rpm: mysql-community-common-5.7.18-1.el6.x86_64 Marking mysql-community-common-5.7.18-1.el6.x86_64.rpm to be installed Examining mysql-community-libs-5.7.18-1.el6.x86_64.rpm: mysql-community-libs-5.7.18-1.el6.x86_64 Marking mysql-community-libs-5.7.18-1.el6.x86_64.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package mysql-community-client.x86_64 0:5.7.18-1.el6 will be installed ---> Package mysql-community-common.x86_64 0:5.7.18-1.el6 will be installed ---> Package mysql-community-libs.x86_64 0:5.7.18-1.el6 will be installed ---> Package mysql-community-server.x86_64 0:5.7.18-1.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================== Package Arch Version Repository Size ================================================================================================================================== Installing: mysql-community-client x86_64 5.7.18-1.el6 /mysql-community-client-5.7.18-1.el6.x86_64 100 M mysql-community-common x86_64 5.7.18-1.el6 /mysql-community-common-5.7.18-1.el6.x86_64 2.5 M mysql-community-libs x86_64 5.7.18-1.el6 /mysql-community-libs-5.7.18-1.el6.x86_64 8.9 M mysql-community-server x86_64 5.7.18-1.el6 /mysql-community-server-5.7.18-1.el6.x86_64 769 M Transaction Summary ================================================================================================================================== Install 4 Package(s) Total size: 880 M Installed size: 880 M Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : mysql-community-common-5.7.18-1.el6.x86_64 1/4 Installing : mysql-community-libs-5.7.18-1.el6.x86_64 2/4 Installing : mysql-community-client-5.7.18-1.el6.x86_64 3/4 Installing : mysql-community-server-5.7.18-1.el6.x86_64 4/4 Verifying : mysql-community-server-5.7.18-1.el6.x86_64 1/4 Verifying : mysql-community-libs-5.7.18-1.el6.x86_64 2/4 Verifying : mysql-community-common-5.7.18-1.el6.x86_64 3/4 Verifying : mysql-community-client-5.7.18-1.el6.x86_64 4/4 Installed: mysql-community-client.x86_64 0:5.7.18-1.el6 mysql-community-common.x86_64 0:5.7.18-1.el6 mysql-community-libs.x86_64 0:5.7.18-1.el6 mysql-community-server.x86_64 0:5.7.18-1.el6 Complete!
12. 最后檢查,已經(jīng)安裝成功
# rpm -qa|grep mysql mysql-community-client-5.7.18-1.el6.x86_64 mysql-community-libs-5.7.18-1.el6.x86_64 mysql-community-common-5.7.18-1.el6.x86_64 mysql-community-server-5.7.18-1.el6.x86_64
13. 安裝完成,但是啟動(dòng)的時(shí)候遇到了問題:
# service mysqld restart Stopping mysqld: [ OK ] Initializing MySQL database: 2017-07-11T15:23:50.462866Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-07-11T15:23:50.465315Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting. 2017-07-11T15:23:50.465365Z 0 [ERROR] Aborting [FAILED]
14. 百度的解決方法(是由于之前老版本的數(shù)據(jù)庫(kù)已經(jīng)占用這個(gè)文件夾,需要清空,或者在/etc/my.cnf中重新指定--datadir)
保證 --datadir目錄為空。 /usr/local/var/mysql 這個(gè)目錄
15. 啟動(dòng)成功
# cd /var/lib/mysql # ls auto.cnf ib_buffer_pool ibdata1 ib_logfile0 ib_logfile1 # rm * rm: remove regular file `auto.cnf'? y rm: remove regular file `ib_buffer_pool'? y rm: remove regular file `ibdata1'? y rm: remove regular file `ib_logfile0'? y rm: remove regular file `ib_logfile1'? y
# service mysqld restart
Stopping mysqld: [ OK ] Initializing MySQL database: [ OK ] Installing validate password plugin: [ OK ] Starting mysqld: [ OK ]
# ps -ef|grep mysql
root 4533 1 0 23:25 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql mysql 4727 4533 4 23:25 pts/0 00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock root 4762 3752 0 23:25 pts/0 00:00:00 grep mysql
16. 然而啟動(dòng)的過程中,又遇到一些問題,密碼不知道了,重置密碼
# mysql -u root ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) [root@test mysql]# mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
編輯mysql配置文件/etc/my.cnf,在[mysqld]這個(gè)條目下加入 skip-grant-tables 保存退出后重啟mysql
# vi /etc/my.cnf
[root@test mysql]# service mysqld restart Stopping mysqld: [ OK ] Starting mysqld: [ OK ]
# mysql
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.18 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 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec)
設(shè)置密碼,然后刪除/etc/my.cnf中的 skip-grant-tables
再次重啟mysql
mysql> use mysql; Database changed
--.給root用戶設(shè)置新密碼:
5.7版本之前:
mysql> update user set password=password("新密碼") where user="root"; Query OK, 1 rows affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0
在5.7版本之后,mysql數(shù)據(jù)庫(kù)下已經(jīng)沒有password這個(gè)字段了,password字段改成了authentication_string。
update mysql.user set authentication_string=PASSWORD('oracle') where User='root';
mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
---退出mysql,重啟然后重新登錄
# service mysqld restart Stopping mysqld: [ OK ] Starting mysqld: [ OK ]
# mysql -uroot -poracle
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 5 Server version: 5.7.18 Copyright (c) 2000, 2017, 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>
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。