mysql 5.6 for linux install(three types)

liqilin0429發表於2015-04-22


MySQL安裝文件



RPM包安裝方式



安裝伺服器端



[root@master mysql]# rpm
-ivh MySQL-server-advanced-5.6.24-1.rhel5.x86_64.rpm



Preparing...               
########################################### [100%]



  
1:MySQL-server-advanced 
########################################### [100%]



warning: user mysql does not exist - using
root



warning: group mysql does not exist - using
root



2015-04-20 18:22:59 0 [Warning] TIMESTAMP
with implicit DEFAULT value is deprecated. Please use
--explicit_defaults_for_timestamp server option (see documentation for more
details).



2015-04-20 18:22:59 0 [Note]
/usr/sbin/mysqld (mysqld 5.6.24-enterprise-commercial-advanced) starting as
process 14012 ...



2015-04-20 18:23:08 14034 [Note] InnoDB:
Shutdown completed; log sequence number 1625987



..........



New default config file was created as
/usr/my.cnf and



will be used by default by the server when
you start it.



You may edit this file to change server
settings





[root@master mysql]#
service mysql status



MySQL is not running                                       [FAILED]



[root@master mysql]#
service mysql start



Starting MySQL......                                       [  OK  ]



[root@master mysql]#
service mysql status



MySQL running
(14203)                                     
[  OK  ]



安裝MYSQL 客戶端



[root@master mysql]# rpm -ivh
MySQL-client-advanced-5.6.24-1.rhel5.x86_64.rpm



Preparing...               
########################################### [100%]



  
1:MySQL-client-advanced 
########################################### [100%]





登陸(密碼在vi  /root/.mysql_secret



# The random password set for the root user
at Mon Apr 20 18:23:04 2015 (local time): hSRBmL148_WYgHsD



[root@master mysql]# mysql -uroot -p



Enter password:



Welcome to the MySQL monitor.  Commands end with ; or \g.



Your MySQL connection id is 5



Server version:
5.6.24-enterprise-commercial-advanced





Copyright (c) 2000, 2015, 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;



ERROR 1820 (HY000): You must SET PASSWORD
before executing this statement



修改MySQL伺服器的密碼



mysql> set password for
root@'localhost'=password("qilin");



Query OK, 0 rows affected (0.00 sec)



查詢RPM包安裝詳細列表



 [root@master
mysql]# rpm -ql MySQL-client-advanced



/usr/bin/msql2mysql



/usr/bin/mysql



/usr/bin/mysql_config_editor



/usr/bin/mysql_find_rows



/usr/bin/mysql_waitpid



/usr/bin/mysqlaccess



/usr/bin/mysqlaccess.conf



/usr/bin/mysqladmin



/usr/bin/mysqlbinlog



/usr/bin/mysqlcheck



/usr/bin/mysqldump



/usr/bin/mysqlimport



/usr/bin/mysqlshow



/usr/bin/mysqlslap



/usr/share/doc/MySQL-client-advanced-5.6.24



/usr/share/doc/MySQL-client-advanced-5.6.24/LICENSE.mysql



/usr/share/man/man1/msql2mysql.1.gz



/usr/share/man/man1/mysql.1.gz



/usr/share/man/man1/mysql_config_editor.1.gz



/usr/share/man/man1/mysql_find_rows.1.gz



/usr/share/man/man1/mysql_waitpid.1.gz



/usr/share/man/man1/mysqlaccess.1.gz



/usr/share/man/man1/mysqladmin.1.gz



/usr/share/man/man1/mysqlbinlog.1.gz



/usr/share/man/man1/mysqlcheck.1.gz



/usr/share/man/man1/mysqldump.1.gz



/usr/share/man/man1/mysqlimport.1.gz



/usr/share/man/man1/mysqlshow.1.gz



解除安裝安裝包



[root@master mysql]# rpm -e MySQL-client-advanced



原始碼編譯安裝方式



安裝系統的包(Cmake所需要)



建立目錄



[root@master ~]# mkdir -p /mnt/flash



掛載光碟



[root@master ~]# mount /mnt/flash
/dev/cdrom



mount: /mnt/flash is not a block device



[root@master ~]# cd /mnt/flash



[root@master flash]# ls



blafdoc.css 
ClusterStorage  eula.en_US  GPL    
isolinux   README-en.html    RELEASE-NOTES-en.html  RPM-GPG-KEY-oracle  supportinfo 
VT



Cluster     
EULA            eula.py     images 
README-en  RELEASE-NOTES-en  RPM-GPG-KEY            Server              TRANS.TBL



如果無法掛載成功,需要重新啟動伺服器,再次載入光碟就可以



安裝相應的包



[root@master Server]# rpm -ivh gcc* --force
--nodeps



warning: gcc-4.1.2-46.el5.x86_64.rpm:
Header V3 DSA signature: NOKEY, key ID 1e5e0159



Preparing...               
########################################### [100%]



  
1:gcc                   
########################################### [ 10%]



  
2:gcc44                  ###########################################
[ 20%]



  
3:gcc-c++               
########################################### [ 30%]



  
4:gcc-objc              
########################################### [ 40%]



  
5:gcc44-c++             
########################################### [ 50%]



  
6:gcc44-gfortran        
########################################### [ 60%]



  
7:gcc-gfortran          
########################################### [ 70%]



  
8:gcc-gnat              
########################################### [ 80%]



  
9:gcc-java              
########################################### [ 90%]



 
10:gcc-objc++            
########################################### [100%]



[root@master Server]#



Cmake安裝部署



下載Cmake包(原始碼包)



http://www.cmake.org/download/



編譯



root@master cmake-2.8.12.2]# ./bootstrap



........



-- Generating done



-- Build files have been written to:
/root/soft/source/cmake/cmake-2.8.12.2



---------------------------------------------



CMake has bootstrapped.  Now run gmake.



[root@master cmake-2.8.12.2]# make



........



[ 99%] Built target pseudo_BC



[ 99%] Building CXX object
Tests/CTestTestMemcheck/CMakeFiles/pseudo_purify.dir/ret0.cxx.o



Linking CXX executable purify



[ 99%] Built target pseudo_purify



[100%] Building CXX object Tests/CTestTestMemcheck/CMakeFiles/pseudo_valgrind.dir/ret0.cxx.o



Linking CXX executable valgrind



[100%] Built target pseudo_valgrind



Scanning dependencies of target pseudonl_BC



[100%] Building C object
Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeFiles/pseudonl_BC.dir/ret0.c.o



Linking C executable BC



[100%] Built target pseudonl_BC



Scanning dependencies of target
pseudonl_purify



[100%] Building C object
Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeFiles/pseudonl_purify.dir/ret0.c.o



Linking C executable purify



[100%] Built target pseudonl_purify



Scanning dependencies of target
pseudonl_valgrind



[100%] Building C object
Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeFiles/pseudonl_valgrind.dir/ret0.c.o



Linking C executable valgrind



[100%] Built target pseudonl_valgrind





[root@master cmake-2.8.12.2]# make install



........



-- Installing:
/usr/local/doc/cmake-2.8/cpack.docbook



-- Installing:
/usr/local/doc/cmake-2.8/ccmake.docbook



-- Up-to-date:
/usr/local/share/aclocal/cmake.m4



-- Up-to-date: /usr/local/share/cmake-2.8/editors/vim/cmake-help.vim



-- Up-to-date:
/usr/local/share/cmake-2.8/editors/vim/cmake-indent.vim



-- Up-to-date:
/usr/local/share/cmake-2.8/editors/vim/cmake-syntax.vim



-- Up-to-date:
/usr/local/share/cmake-2.8/editors/emacs/cmake-mode.el



-- Up-to-date:
/usr/local/share/cmake-2.8/completions/cmake



-- Up-to-date:
/usr/local/share/cmake-2.8/completions/cpack



-- Up-to-date:
/usr/local/share/cmake-2.8/completions/ctest



解壓



[root@master cmake]# tar -zxvf
cmake-3.2.2-Linux-x86_64.tar.gz



編譯



在編譯時會報各種各樣的錯誤,是由於缺少相應的包(kernel*libc*libgn*libc*glibc*gmp*bison.i686gcc-c++ncurses.i686),導致了各種錯誤的產生



[root@master cmake-2.8.12.2]# ./bootstrap



[root@master cmake-2.8.12.2]#



[root@master cmake-2.8.12.2]# make
&& make install



建立使用者組合使用者



[root@master ~]# groupadd mysql



groupadd: group mysql exists



[root@master ~]# groupdel mysqsl



groupdel: group mysqsl does not exist



[root@master ~]# groupdel mysql



groupdel: cannot remove
user's primary group.



因為這個組mysql裡面還有使用者。所以在刪除使用者組前,一定要檢視這個組中還有沒有成員了。



 [root@master
~]# tail -n 7 /etc/group /etc/gshadow



==> /etc/group <==



dbus:x:81:



avahi:x:70:



haldaemon:x:68:



avahi-autoipd:x:101:



gdm:x:42:



sabayon:x:86:



mysql:x:102:





==> /etc/gshadow <==



dbus:x::



avahi:x::



haldaemon:x::



avahi-autoipd:x::



gdm:x::



sabayon:x::



mysql:!::



[root@master ~]# userdel mysql



[root@master ~]# tail -n 7 /etc/group
/etc/gshadow



==> /etc/group <==



nfsnobody:x:4294967294:



dbus:x:81:



avahi:x:70:



haldaemon:x:68:



avahi-autoipd:x:101:



gdm:x:42:



sabayon:x:86:





==> /etc/gshadow <==



nfsnobody:x::



dbus:x::



avahi:x::



haldaemon:x::



avahi-autoipd:x::



gdm:x::



sabayon:x::





[root@master ~]# groupadd mysql



[root@master ~]# useradd -g mysql mysql



建立安裝目錄及資料庫存放目錄



[root@master ~]# mkdir -p /usr/local/mysql       --安裝MySQL



[root@master ~]# mkdir -p
/usr/local/mysql/data   --
存放資料庫



設定目錄許可權



[root@master ~]# cd /usr/local/mysql



[root@master mysql]# chown -R root:mysql



chown: missing operand after `root:mysql'



Try `chown --help' for more information.



[root@master mysql]# chown -R root:mysql .  
--
把當前目錄中所有檔案的所有者所有者設為root,所屬組為mysql



[root@master mysql]# chown -R mysql:mysql
data



修改系統資源的限制



安裝MySQL



解壓



[root@master mysql-5.6.17]# unzip
mysql-5.6.17.zip



安裝



[root@master mysql-5.6.17]#cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \  -DMYSQL_DATADIR=/usr/local/mysql/data \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \



-DEXTRA_CHARSETS=all \

-DENABLED_LOCAL_INFILE=1 \



-DMYSQL_USER=mysql  



注意一



      在初次cmake,有報錯誤時,需要重新重新編譯時,必須清除舊的物件檔案和快取資訊。



[root@master
cmake-2.8.12.2]# make clean



[root@master
cmake-2.8.12.2]# rm -f CMakeC



 [root@master cmake-2.8.12.2]# rm -f
CMakeCache.txt



注意二



     如果再安裝了相應的包後,還是報同樣的錯誤。把MySQL原始碼解壓包刪除了,從新解壓一次,再次執行上面的語句就可以了





[root@master mysql-5.6.17]# make



[root@master mysql-5.6.17]# make
install





新增MySQL自動啟動到系統服務中(可選)



[root@master ~]# cp
support-files/my-medium.cnf /etc/my.cnf
 //mysql的啟動服務新增到系統服務中



建立系統資料庫的表



[root@master mysql]# pwd



/usr/local/mysql



[root@master mysql]#
scripts/mysql_install_db --user=mysql





設定環境變數



[root@master ~]# pwd



/root



[root@master ~]# vi .bash_profile



PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib



:/usr/local/mysql/bin:/usr/local/mysql/lib需要在.bash_profile



檔案的PATH中新增



[root@master ~]# source .bash_profile





手動啟動



[root@master mysql]# pwd



/usr/local/mysql



[root@master mysql]# ./bin/mysqld_safe
--user=mysql &



[1] 3004



[root@master mysql]# 150421 19:27:56
mysqld_safe Logging to '/usr/local/mysql/data/master.err'.



150421 19:27:56 mysqld_safe Starting mysqld
daemon with databases from /usr/local/mysql/data





手動關閉



[root@master
mysql]#
mysqladmin -u root -p shutdown 



Enter password:



這裡MySQLroot使用者還沒有配置密碼,所以為空值。需要輸入密碼時,直接點Enter鍵即可。





修改MySQLroot使用者密碼以及開啟遠端連線



[root@master ~]# mysql -uroot -p



Enter password:



Welcome to the MySQL monitor.  Commands end with ; or \g.



Your MySQL connection id is 2



Server version: 5.6.17 Source distribution





Copyright (c) 2000, 2014, 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>



mysql> show databases;



+--------------------+



| Database           |



+--------------------+



| information_schema |



| mysql              |



| performance_schema |



| test               |



+--------------------+



4 rows in set (0.00 sec)





mysql> use mysql;



Database changed



mysql> desc user;



+------------------------+-----------------------------------+------+-----+---------+-------+



| Field                  | Type                              | Null | Key | Default
| Extra |



+------------------------+-----------------------------------+------+-----+---------+-------+



.......



| authentication_string  | text                              | YES  |     |
NULL    |       |



| password_expired       | enum('N','Y')                     | NO   |    
| N       |       |



+------------------------+-----------------------------------+------+-----+---------+-------+



43 rows in set (0.00 sec)



開啟遠端連線



mysql> grant all privileges on * * to root@"%"
identified by "root";



ERROR 1064 (42000): You have an error in
your SQL syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near '* to root@"%" identified by
"root"' at line 1



mysql> GRANT ALL PRIVILEGES ON *.* TO
root@"%" IDENTIFIED BY "root";



Query OK, 0 rows affected (0.00 sec)



修改密碼



mysql> update user set
Password=password('qilin') where User='root';



Query OK, 5 rows affected (0.03 sec)



Rows matched: 5  Changed: 5 
Warnings: 0





mysql> select Host,User,Password from
user where User='root';



+-----------+------+-------------------------------------------+



| Host     
| User | Password                                  |



+-----------+------+-------------------------------------------+



| localhost | root |
*A510E0B2BBC95E9DAD498681F2DDD77A9B642EB6 |



| master   
| root | *A510E0B2BBC95E9DAD498681F2DDD77A9B642EB6 |



| 127.0.0.1 | root |
*A510E0B2BBC95E9DAD498681F2DDD77A9B642EB6 |



| ::1      
| root | *A510E0B2BBC95E9DAD498681F2DDD77A9B642EB6 |



| %        
| root | *A510E0B2BBC95E9DAD498681F2DDD77A9B642EB6 |



+-----------+------+-------------------------------------------+



5 rows in set (0.00 sec)





mysql> flush privileges;



Query OK, 0 rows affected (0.00 sec)





mysql> exit



Bye



重新登入驗證設定的密碼



[root@master ~]# mysql -uroot -p



Enter password:



Welcome to the MySQL monitor.  Commands end with ; or \g.



Your MySQL connection id is 3



Server version: 5.6.17 Source distribution





Copyright (c) 2000, 2014, 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>



二進位制包安裝方式



下載二進位制包



下載二進位制包檔名類似為:mysql-VERSION-OS-PLATFORM.tar.gz



選擇二進位制版本的優點是:第一
它是針對特定平臺專門優化過的,安裝時不需要考慮環境是否符合要求(不用單獨安裝CMAKE,LINUX6.0後,CMAKE自動安裝在作業系統中);第二
安裝簡單,直接解壓就可以了。



建立使用者組和使用者



建立相應的目錄



授予相應的許可權



解壓



[root@slave soft]# tar -zxvf
mysql-5.5.41-linux2.6-x86_64.tar.gz  -C
/usr/local/mysql



解壓到了指定的目錄下,



在原始碼包的基礎上建立二進位制包,就可以利用原始碼包的定製效能和二進位制包的可移植特性,通過使以下下打包命令



[root@master mysql-5.6.17]# tar -cvfz
/root/mysql-5.6.tar.gz /root/soft/source/source_package/mysql-5.6.17/



這樣就會建立一份二進位制包()了,這個包就是我們使用二進位制包來進行安裝的安裝包了,如果有其他伺服器安裝MYSQL,我們只要將這個包複製到相應的目錄下,進行指定目錄的解壓就可以了。比如建立使用者,建立目錄,授予許可權再次執行就可以了



其他操作



剩下的步驟與原始碼安裝編譯後的步驟一致



把原始碼編譯安裝完成的,



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/20976446/viewspace-1591597/,如需轉載,請註明出處,否則將追究法律責任。

相關文章