CentOS 6.5上安裝MariaDB

來源:互聯網
上載者:User

CentOS 6.5上安裝MariaDB作者:chszs,轉載需註明。部落客頁:http://blog.csdn.net/chszs

1、軟體環境:CentOS 6.5 x64
MariaDB 5.5.36

2、安裝過程1)在/etc/yum.repos.d/目錄建立MariaDB.repo檔案,內容如下:

# MariaDB 5.5 CentOS repository list - created 2014-03-04 11:20 UTC# http://mariadb.org/mariadb/repositories/[mariadb]name = MariaDBbaseurl = http://yum.mariadb.org/5.5/centos6-amd64gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDBgpgcheck=1

2)在Shell環境下執行命令
# yum install MariaDB-server MariaDB-clientLoaded plugins: fastestmirror, securitybase                                                                                       | 3.7 kB     00:00     base/primary_db                                                                            | 4.4 MB     01:11     extras                                                                                     | 3.4 kB     00:00     extras/primary_db                                                                          |  19 kB     00:00     mariadb                                                                                    | 1.9 kB     00:00     mariadb/primary_db                                                                         |  15 kB     00:00     updates                                                                                    | 3.4 kB     00:00     updates/primary_db                                                                         | 2.1 MB     00:22     Setting up Install ProcessResolving Dependencies--> Running transaction check---> Package MariaDB-client.x86_64 0:5.5.36-1.el6 will be obsoleting--> Processing Dependency: MariaDB-common for package: MariaDB-client-5.5.36-1.el6.x86_64---> Package MariaDB-server.x86_64 0:5.5.36-1.el6 will be obsoleting---> Package mysql.x86_64 0:5.1.71-1.el6 will be obsoleted---> Package mysql-server.x86_64 0:5.1.71-1.el6 will be obsoleted--> Running transaction check---> Package MariaDB-common.x86_64 0:5.5.36-1.el6 will be installed--> Processing Dependency: MariaDB-compat for package: MariaDB-common-5.5.36-1.el6.x86_64--> Running transaction check---> Package MariaDB-compat.x86_64 0:5.5.36-1.el6 will be obsoleting---> Package mysql-libs.x86_64 0:5.1.71-1.el6 will be obsoleted--> Finished Dependency ResolutionDependencies Resolved================================================================================================================== Package                        Arch                   Version                      Repository               Size==================================================================================================================Installing: MariaDB-client                 x86_64                 5.5.36-1.el6                 mariadb                  10 M     replacing  mysql.x86_64 5.1.71-1.el6 MariaDB-compat                 x86_64                 5.5.36-1.el6                 mariadb                 2.7 M     replacing  mysql-libs.x86_64 5.1.71-1.el6 MariaDB-server                 x86_64                 5.5.36-1.el6                 mariadb                  42 M     replacing  mysql-server.x86_64 5.1.71-1.el6Installing for dependencies: MariaDB-common                 x86_64                 5.5.36-1.el6                 mariadb                  23 kTransaction Summary==================================================================================================================Install       4 Package(s)Total download size: 55 MIs this ok [y/N]: yDownloading Packages:(1/4): MariaDB-5.5.36-centos6-x86_64-client.rpm                                            |  10 MB     04:45     (2/4): MariaDB-5.5.36-centos6-x86_64-common.rpm                                            |  23 kB     00:00     (3/4): MariaDB-5.5.36-centos6-x86_64-compat.rpm                                            | 2.7 MB     01:02     (4/4): MariaDB-5.5.36-centos6-x86_64-server.rpm                                            |  42 MB     17:44     ------------------------------------------------------------------------------------------------------------------Total                                                                              40 kB/s |  55 MB     23:34     warning: rpmts_HdrFromFdno: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEYRetrieving key from https://yum.mariadb.org/RPM-GPG-KEY-MariaDBImporting GPG key 0x1BB943DB: Userid: "Daniel Bartholomew (Monty Program signing key) <dbart@askmonty.org>" From  : https://yum.mariadb.org/RPM-GPG-KEY-MariaDBIs this ok [y/N]: yRunning rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction  Installing : MariaDB-compat-5.5.36-1.el6.x86_64                                                             1/7   Installing : MariaDB-common-5.5.36-1.el6.x86_64                                                             2/7 Error in PREIN scriptlet in rpm package MariaDB-server-5.5.36-1.el6.x86_64******************************************************************A MySQL or MariaDB server package (mysql-server-5.1.71-1.el6.x86_64) is installed.The current MariaDB server package is provided by a differentvendor (CentOS) than Monty Program AB.  Some files may be installedto different locations, including log files and the servicestartup script in /etc/init.d/.Upgrading directly from MySQL 5.1 to MariaDB 5.5 may notbe safe in all cases.  A manual dump and restore using mysqldump isrecommended.  It is important to review the MariaDB manual's Upgradingsection for version-specific incompatibilities.A manual upgrade is required.- Ensure that you have a complete, working backup of your data and my.cnf  files- Shut down the MySQL server cleanly- Remove the existing MySQL packages.  Usually this command will  list the packages you should remove:  rpm -qa | grep -i '^mysql-'  You may choose to use 'rpm --nodeps -ev <package-name>' to remove  the package which contains the mysqlclient shared library.  The  library will be reinstalled by the MariaDB-shared package.- Install the new MariaDB packages supplied by Monty Program AB- Ensure that the MariaDB server is started- Run the 'mysql_upgrade' programThis is a brief description of the upgrade process.  Important detailscan be found in the MariaDB manual, in the Upgrading section.******************************************************************error: %pre(MariaDB-server-5.5.36-1.el6.x86_64) scriptlet failed, exit status 1error:   install: %pre scriptlet failed (2), skipping MariaDB-server-5.5.36-1.el6  Installing : MariaDB-client-5.5.36-1.el6.x86_64                                                             4/7   Erasing    : mysql-5.1.71-1.el6.x86_64                                                                      5/7   Erasing    : mysql-libs-5.1.71-1.el6.x86_64                                                                 6/7   Verifying  : MariaDB-common-5.5.36-1.el6.x86_64                                                             1/7   Verifying  : MariaDB-compat-5.5.36-1.el6.x86_64                                                             2/7   Verifying  : MariaDB-client-5.5.36-1.el6.x86_64                                                             3/7   Verifying  : mysql-libs-5.1.71-1.el6.x86_64                                                                 4/7   Verifying  : MariaDB-server-5.5.36-1.el6.x86_64                                                             5/7 mysql-server-5.1.71-1.el6.x86_64 was supposed to be removed but is not!  Verifying  : mysql-server-5.1.71-1.el6.x86_64                                                               6/7   Verifying  : mysql-5.1.71-1.el6.x86_64                                                                      7/7 Installed:  MariaDB-client.x86_64 0:5.5.36-1.el6                    MariaDB-compat.x86_64 0:5.5.36-1.el6                   Dependency Installed:  MariaDB-common.x86_64 0:5.5.36-1.el6                                                                            Replaced:  mysql.x86_64 0:5.1.71-1.el6                           mysql-libs.x86_64 0:5.1.71-1.el6                          Failed:  MariaDB-server.x86_64 0:5.5.36-1.el6                     mysql-server.x86_64 0:5.1.71-1.el6                    Complete!

3、啟動MariaDB
# /etc/init.d/mysqld startInitializing MySQL database:  WARNING: The host 'Cloud-Q2' could not be looked up with resolveip.This probably means that your libc libraries are not 100 % compatiblewith this binary MySQL version. The MySQL daemon, mysqld, should worknormally with the exception that host name resolving will not work.This means that you should use IP addresses instead of hostnameswhen specifying MySQL privileges !Installing MySQL system tables...OKFilling help tables...OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE 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 Cloud-Q2 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.You can start the MySQL daemon with:cd /usr ; /usr/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.plcd /usr/mysql-test ; perl mysql-test-run.plPlease report any problems with the /usr/bin/mysqlbug script!                                                           [  OK  ]Starting mysqld:                                           [  OK  ]

4、為MariaDB設定密碼
# /usr/bin/mysqladmin -u root password 'adminadmin'

登陸MariaDB
MySQL [(none)]> use mysql;MySQL [mysql]> update user set host='%' where user='root' and host='127.0.0.1';MySQL [mysql]> grant all privileges on *.* to 'root'@'%' identified by 'adminadmin' with grant option;MySQL [mysql]> flush privileges;

5、讓防火牆通過3306連接埠
# vi /etc/sysconfig/iptables

添加如下內容:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

儲存並退出編輯
重啟防火牆服務
# service iptables restart

遠端連線檢查,一切OK!







相關文章

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.