centos6.5安裝mysql5.6,centos6.5mysql5.6

來源:互聯網
上載者:User

centos6.5安裝mysql5.6,centos6.5mysql5.6
1. 先查看版本號碼

# uname -a
2. 下載並安裝Mysql的yum倉庫

下載Mysql的yum倉庫

http://dev.mysql.com/downloads/repo/yum/

然後安裝一下這個倉庫列表

$ sudo yum localinstall mysql-community-release-el6-5.noarch.rpm 
3. 搜尋可安裝的mysql版本

執行這個命令後就能看到可安裝的mysql:

# yum repolist enabled | grep "mysql.*-community.*"

如果我們是要安裝最新的版本,那麼可以直接執行

# sudo yum install mysql-community-server

如果我們要選擇版本,可以先執行下面這個命令查看一下有哪些版本:

# yum repolist all | grep mysql

如果要選擇版本的話,有兩種方式,一種是使用命令來

$ sudo yum-config-manager --disable mysql56-community$ sudo yum-config-manager --enable mysql57-community-dmr

這個命令就是在倉庫中啟用5.7版本的,禁用5.6版本子倉庫
或者編輯/etc/yum.repos.d/mysql-community.repo檔案

# Enable to use MySQL 5.6[mysql56-community]name=MySQL 5.6 Community Serverbaseurl=//repo.mysql.com/yum/mysql-5.6-community/el/5/$basearch/enabled=1gpgcheck=1gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 

enabled=0表示禁用
比如要安裝5.7版本的mysql,要確定5.6的enabled=0,5.7的enabled=1,一次保證只啟用一個子倉庫

# Note: MySQL 5.7 is currently in development. For use at your own risk.# Please read with sub pages: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/[mysql57-community-dmr]name=MySQL 5.7 Community Server Development Milestone Releasebaseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/enabled=1gpgcheck=1gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

然後我們又可以愉快的安裝mysql了

$ sudo yum install mysql-community-server

安裝完成後我們啟動mysql

$ sudo service mysqld start

查看mysql狀態

$ sudo service mysqld status

啟動mysql服務並初始化:

# /etc/init.d/mysqld startInitializing MySQL database: PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands:/usr/bin/mysqladmin -u root password 'new-password'/usr/bin/mysqladmin -u root -h iZ94vana2fdZ password 'new-password'Alternatively you can run:/usr/bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly recommended for production servers.See the manual for more instructions.Please report any problems at http://bugs.mysql.com/[ OK ]Starting mysqld: [ OK ]
4. 相關命令

啟動mysql服務

# service mysqld start

重啟mysql服務

# service mysqld restart

停止mysql服務

# service mysqld stop

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.