CentOS6.5 rpm安裝mysql5.6


CentOS6.5 rpm安裝mysql5.6

系統版本:Linux centos6 2.6.32-431.el6.x86_64
mysql版本:MySQL-5.6.38-1.el6.x86_64

1.mysql5.6 rpm包下載

進入mysql官網下載頁
https://dev.mysql.com/downloads

 

 

點擊MySQL Community Server (GPL)版本下的DOWNLOAD按鈕進入Download MySQL Community Server頁面

 

 


點擊MySQL Community Server 5.6 »超鏈接進入mysql5.6下載頁
由於mysql5.7早已發布,目前官網下載頁面只提供了mysql 5.6.38的下載

 

 


這里選擇下載MySQL-5.6.38-1.el6.x86_64.rpm-bundle.tar打包版本

 

 

 

 

 

 

2.rpm安裝mysql5.6

2.1查看CentOS6自帶的mysql並卸載

[root@centos6 ~]# rpm -qa | grep mysql [root@centos6 ~]# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64 

如果不卸載會在安裝mysql時會出現如下的情況
warning: MySQL-server-5.6.38-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-server-5.6.38-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64 file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.6.38-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64 file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.6.38-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64 file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.6.38-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64 file /usr/share/mysql/estonian/errmsg.sys from install of MySQL-server-5.6.38-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64 file /usr/share/mysql/french/errmsg.sys from install of MySQL-server-5.6.38-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64 file /usr/share/mysql/german/errmsg.sys from install of MySQL-server-5.6.38-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64 file /usr/share/mysql/greek/errmsg.sys from install of MySQL-server-5.6.38-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64 file /usr/share/mysql/hungarian/errmsg.sys from install of MySQL-server-5.6.38-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64 file /usr/share/mysql/italian/errmsg.sys from install of MySQL-server-5.6.38-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.71-1.el6.x86_64 

2.2上傳mysql5.6 rpm包

2.3解壓安裝

解壓上傳的tar包

[root@centos6 ~]# tar -xvf MySQL-5.6.38-1.el6.x86_64.rpm-bundle.tar

解壓后會得到以下rpm安裝文件:

MySQL-client-5.6.38-1.el6.x86_64.rpm
MySQL-devel-5.6.38-1.el6.x86_64.rpm
MySQL-embedded-5.6.38-1.el6.x86_64.rpm
MySQL-server-5.6.38-1.el6.x86_64.rpm
MySQL-shared-5.6.38-1.el6.x86_64.rpm
MySQL-shared-compat-5.6.38-1.el6.x86_64.rpm
MySQL-test-5.6.38-1.el6.x86_64.rpm

安裝服務端

[root@centos6 ~]# rpm -ivh MySQL-server-5.6.38-1.el6.x86_64.rpm

報error: Failed dependencies的錯誤,缺少perl、libaio.so.1(64bit)、libnuma.so.1(64bit)的依賴,具體信息如下:
warning: MySQL-server-5.6.38-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:

    /usr/bin/perl is needed by MySQL-server-5.6.38-1.el6.x86_64 libaio.so.1()(64bit) is needed by MySQL-server-5.6.38-1.el6.x86_64 libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.6.38-1.el6.x86_64 libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.6.38-1.el6.x86_64 libnuma.so.1()(64bit) is needed by MySQL-server-5.6.38-1.el6.x86_64 libnuma.so.1(libnuma_1.1)(64bit) is needed by MySQL-server-5.6.38-1.el6.x86_64 libnuma.so.1(libnuma_1.2)(64bit) is needed by MySQL-server-5.6.38-1.el6.x86_64 

解決缺少perl的依賴:

[root@centos6 ~]# yum install -y perl

解決缺少libaio.so.1(64bit)的依賴:
這里使用yum install –y libaio.so.1后發現並不能解決問題,原因yum安裝的並非x86_64版本,而是i686版本

[root@centos6 ~]# rpm -qa | grep libaio
libaio-0.3.107-10.el6.i686

手動下載libaio-0.3.107-10.el6.x86_64.rpm,下載地址如下:
http://mirror.centos.org/cent...
上傳后安裝

[root@centos6 ~]# rpm -ivh libaio-0.3.107-10.el6.x86_64.rpm

解決缺少libnuma.so.1(64bit)依賴:

[root@centos6 ~]# yum install -y numactl 

安裝完成后提示默認為root用戶設置了隨機密碼,可以在/root/.mysql_secret文件中找到,並且移除了匿名用戶,可以運行/usr/bin/mysql_secure_installation命令來移除自帶的測試數據庫,還生成了默認配置文件/usr/my.cnf

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER ! You will find
that password in '/root/.mysql_secret'.

You must change that password on your first connect, no other
statement but 'SET PASSWORD' will be accepted. See the manual for the
semantics of the 'password expired' flag.

Also, the account for the anonymous user has been removed.

In addition, you can run:

/usr/bin/mysql_secure_installation

which will also give you the option of removing the test database.
This is strongly recommended for production servers.

See the manual for more instructions.

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

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@centos6 ~]# rpm -ivh MySQL-client-5.6.38-1.el6.x86_64.rpm 

2.4啟動mysql設置root密碼

啟動mysql服務

[root@centos6 ~]# service mysql start 
[root@centos6 ~]# service mysql start Starting MySQL.Logging to
'/var/lib/mysql/centos6.err'. .... SUCCESS!
[root@centos6 ~]# service
mysql status SUCCESS! MySQL running (1620)

查看默認生成的隨機密碼

[root@centos6 ~]# cat /root/.mysql_secret 

使用隨機密碼登錄mysql

[root@centos6 ~]# mysql -u root -p 

設置密碼,這里設置為mysql123

mysql> set password = password('mysql123'); 

2.5開啟mysql的遠程登錄

默認情況下mysql為安全起見,不支持遠程登錄mysql,因此需要設置開啟遠程登錄mysql的權限
登錄mysql后輸入如下命令:

mysql> grant all privileges on *.* to 'root' @'%' identified by 'mysql123'; mysql> flush privileges; 

2.6設置開機啟動

加入到系統服務

[root@centos6 ~]# chkconfig --add mysql 

開機自啟

[root@centos6 ~]# chkconfig mysql on 

2.7開放Linux的對外訪問的端口3306

mysql默認沒有開啟對外訪問端口3306,需要手動開啟

[root@centos6 ~]# /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT [root@centos6 ~]# /etc/rc.d/init.d/iptables save 

2.8刪除測試數據庫

運行提示的/usr/bin/mysql_secure_installation命令來刪除測試數據庫

[root@centos6 ~]# /usr/bin/mysql_secure_installation 

[root@centos6 ~]# /usr/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

  SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! 

In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and you
haven't set the root password yet, the password will be blank, so you
should just press enter here.

Enter current password for root (enter for none): OK, successfully
used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n ... skipping.

By default, a MySQL installation has an anonymous user, allowing
anyone to log into MySQL without having to have a user account created
for them. This is intended only for testing, and to make the
installation go a bit smoother. You should remove them before moving
into a production environment.

Remove anonymous users? [Y/n] y ... Success!

Normally, root should only be allowed to connect from 'localhost'.
This ensures that someone cannot guess at the root password from the
network.

Disallow root login remotely? [Y/n] n ... skipping.

By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y

  • Dropping test database... ... Success!
  • Removing privileges on test database... ... Success!

Reloading the privilege tables will ensure that all changes made so
far will take effect immediately.

Reload privilege tables now? [Y/n] y ... Success!

All done! If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

2.9幾個重要目錄

數據庫目錄
  /var/lib/mysql/
配置文件
  /usr/share/mysql(mysql.server命令及配置文件)
相關命令
  /usr/bin(mysqladmin mysqldump等命令)
啟動腳本
  /etc/rc.d/init.d/(啟動腳本文件mysql的目錄)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM