CentOS 6.5上安装MariaDB

来源:互联网 发布:维棠flv下载器 mac 编辑:程序博客网 时间:2024/05/16 07:06

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文件,内容如下:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. # MariaDB 5.5 CentOS repository list - created 2014-03-04 11:20 UTC  
  2. # http://mariadb.org/mariadb/repositories/  
  3. [mariadb]  
  4. name = MariaDB  
  5. baseurl = http://yum.mariadb.org/5.5/centos6-amd64  
  6. gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB  
  7. gpgcheck=1  

2)在Shell环境下执行命令
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. # yum install MariaDB-server MariaDB-client  
  2. Loaded plugins: fastestmirror, security  
  3. base                                                                                       | 3.7 kB     00:00       
  4. base/primary_db                                                                            | 4.4 MB     01:11       
  5. extras                                                                                     | 3.4 kB     00:00       
  6. extras/primary_db                                                                          |  19 kB     00:00       
  7. mariadb                                                                                    | 1.9 kB     00:00       
  8. mariadb/primary_db                                                                         |  15 kB     00:00       
  9. updates                                                                                    | 3.4 kB     00:00       
  10. updates/primary_db                                                                         | 2.1 MB     00:22       
  11. Setting up Install Process  
  12. Resolving Dependencies  
  13. --> Running transaction check  
  14. ---> Package MariaDB-client.x86_64 0:5.5.36-1.el6 will be obsoleting  
  15. --> Processing Dependency: MariaDB-common for package: MariaDB-client-5.5.36-1.el6.x86_64  
  16. ---> Package MariaDB-server.x86_64 0:5.5.36-1.el6 will be obsoleting  
  17. ---> Package mysql.x86_64 0:5.1.71-1.el6 will be obsoleted  
  18. ---> Package mysql-server.x86_64 0:5.1.71-1.el6 will be obsoleted  
  19. --> Running transaction check  
  20. ---> Package MariaDB-common.x86_64 0:5.5.36-1.el6 will be installed  
  21. --> Processing Dependency: MariaDB-compat for package: MariaDB-common-5.5.36-1.el6.x86_64  
  22. --> Running transaction check  
  23. ---> Package MariaDB-compat.x86_64 0:5.5.36-1.el6 will be obsoleting  
  24. ---> Package mysql-libs.x86_64 0:5.1.71-1.el6 will be obsoleted  
  25. --> Finished Dependency Resolution  
  26.   
  27. Dependencies Resolved  
  28.   
  29. ==================================================================================================================  
  30.  Package                        Arch                   Version                      Repository               Size  
  31. ==================================================================================================================  
  32. Installing:  
  33.  MariaDB-client                 x86_64                 5.5.36-1.el6                 mariadb                  10 M  
  34.      replacing  mysql.x86_64 5.1.71-1.el6  
  35.  MariaDB-compat                 x86_64                 5.5.36-1.el6                 mariadb                 2.7 M  
  36.      replacing  mysql-libs.x86_64 5.1.71-1.el6  
  37.  MariaDB-server                 x86_64                 5.5.36-1.el6                 mariadb                  42 M  
  38.      replacing  mysql-server.x86_64 5.1.71-1.el6  
  39. Installing for dependencies:  
  40.  MariaDB-common                 x86_64                 5.5.36-1.el6                 mariadb                  23 k  
  41.   
  42. Transaction Summary  
  43. ==================================================================================================================  
  44. Install       4 Package(s)  
  45.   
  46. Total download size: 55 M  
  47. Is this ok [y/N]: y  
  48. Downloading Packages:  
  49. (1/4): MariaDB-5.5.36-centos6-x86_64-client.rpm                                            |  10 MB     04:45       
  50. (2/4): MariaDB-5.5.36-centos6-x86_64-common.rpm                                            |  23 kB     00:00       
  51. (3/4): MariaDB-5.5.36-centos6-x86_64-compat.rpm                                            | 2.7 MB     01:02       
  52. (4/4): MariaDB-5.5.36-centos6-x86_64-server.rpm                                            |  42 MB     17:44       
  53. ------------------------------------------------------------------------------------------------------------------  
  54. Total                                                                              40 kB/s |  55 MB     23:34       
  55. warning: rpmts_HdrFromFdno: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY  
  56. Retrieving key from https://yum.mariadb.org/RPM-GPG-KEY-MariaDB  
  57. Importing GPG key 0x1BB943DB:  
  58.  Userid: "Daniel Bartholomew (Monty Program signing key) <dbart@askmonty.org>"  
  59.  From  : https://yum.mariadb.org/RPM-GPG-KEY-MariaDB  
  60. Is this ok [y/N]: y  
  61. Running rpm_check_debug  
  62. Running Transaction Test  
  63. Transaction Test Succeeded  
  64. Running Transaction  
  65.   Installing : MariaDB-compat-5.5.36-1.el6.x86_64                                                             1/7   
  66.   Installing : MariaDB-common-5.5.36-1.el6.x86_64                                                             2/7   
  67. Error in PREIN scriptlet in rpm package MariaDB-server-5.5.36-1.el6.x86_64  
  68.   
  69. ******************************************************************  
  70. A MySQL or MariaDB server package (mysql-server-5.1.71-1.el6.x86_64) is installed.  
  71.   
  72. The current MariaDB server package is provided by a different  
  73. vendor (CentOS) than Monty Program AB.  Some files may be installed  
  74. to different locations, including log files and the service  
  75. startup script in /etc/init.d/.  
  76.   
  77. Upgrading directly from MySQL 5.1 to MariaDB 5.5 may not  
  78. be safe in all cases.  A manual dump and restore using mysqldump is  
  79. recommended.  It is important to review the MariaDB manual's Upgrading  
  80. section for version-specific incompatibilities.  
  81.   
  82. A manual upgrade is required.  
  83.   
  84. - Ensure that you have a complete, working backup of your data and my.cnf  
  85.   files  
  86. - Shut down the MySQL server cleanly  
  87. - Remove the existing MySQL packages.  Usually this command will  
  88.   list the packages you should remove:  
  89.   rpm -qa | grep -i '^mysql-'  
  90.   
  91.   You may choose to use 'rpm --nodeps -ev <package-name>' to remove  
  92.   the package which contains the mysqlclient shared library.  The  
  93.   library will be reinstalled by the MariaDB-shared package.  
  94. - Install the new MariaDB packages supplied by Monty Program AB  
  95. - Ensure that the MariaDB server is started  
  96. - Run the 'mysql_upgrade' program  
  97.   
  98. This is a brief description of the upgrade process.  Important details  
  99. can be found in the MariaDB manual, in the Upgrading section.  
  100. ******************************************************************  
  101. error: %pre(MariaDB-server-5.5.36-1.el6.x86_64) scriptlet failed, exit status 1  
  102. error:   install: %pre scriptlet failed (2), skipping MariaDB-server-5.5.36-1.el6  
  103.   Installing : MariaDB-client-5.5.36-1.el6.x86_64                                                             4/7   
  104.   Erasing    : mysql-5.1.71-1.el6.x86_64                                                                      5/7   
  105.   Erasing    : mysql-libs-5.1.71-1.el6.x86_64                                                                 6/7   
  106.   Verifying  : MariaDB-common-5.5.36-1.el6.x86_64                                                             1/7   
  107.   Verifying  : MariaDB-compat-5.5.36-1.el6.x86_64                                                             2/7   
  108.   Verifying  : MariaDB-client-5.5.36-1.el6.x86_64                                                             3/7   
  109.   Verifying  : mysql-libs-5.1.71-1.el6.x86_64                                                                 4/7   
  110.   Verifying  : MariaDB-server-5.5.36-1.el6.x86_64                                                             5/7   
  111. mysql-server-5.1.71-1.el6.x86_64 was supposed to be removed but is not!  
  112.   Verifying  : mysql-server-5.1.71-1.el6.x86_64                                                               6/7   
  113.   Verifying  : mysql-5.1.71-1.el6.x86_64                                                                      7/7   
  114.   
  115. Installed:  
  116.   MariaDB-client.x86_64 0:5.5.36-1.el6                    MariaDB-compat.x86_64 0:5.5.36-1.el6                     
  117.   
  118. Dependency Installed:  
  119.   MariaDB-common.x86_64 0:5.5.36-1.el6                                                                              
  120.   
  121. Replaced:  
  122.   mysql.x86_64 0:5.1.71-1.el6                           mysql-libs.x86_64 0:5.1.71-1.el6                            
  123.   
  124. Failed:  
  125.   MariaDB-server.x86_64 0:5.5.36-1.el6                     mysql-server.x86_64 0:5.1.71-1.el6                      
  126.   
  127. Complete!  

3、启动MariaDB

[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. # /etc/init.d/mysqld start  
  2. Initializing MySQL database:  WARNING: The host 'Cloud-Q2' could not be looked up with resolveip.  
  3. This probably means that your libc libraries are not 100 % compatible  
  4. with this binary MySQL version. The MySQL daemon, mysqld, should work  
  5. normally with the exception that host name resolving will not work.  
  6. This means that you should use IP addresses instead of hostnames  
  7. when specifying MySQL privileges !  
  8. Installing MySQL system tables...  
  9. OK  
  10. Filling help tables...  
  11. OK  
  12.   
  13. To start mysqld at boot time you have to copy  
  14. support-files/mysql.server to the right place for your system  
  15.   
  16. PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !  
  17. To do so, start the server, then issue the following commands:  
  18.   
  19. /usr/bin/mysqladmin -u root password 'new-password'  
  20. /usr/bin/mysqladmin -u root -h Cloud-Q2 password 'new-password'  
  21.   
  22. Alternatively you can run:  
  23. /usr/bin/mysql_secure_installation  
  24.   
  25. which will also give you the option of removing the test  
  26. databases and anonymous user created by default.  This is  
  27. strongly recommended for production servers.  
  28.   
  29. See the manual for more instructions.  
  30.   
  31. You can start the MySQL daemon with:  
  32. cd /usr ; /usr/bin/mysqld_safe &  
  33.   
  34. You can test the MySQL daemon with mysql-test-run.pl  
  35. cd /usr/mysql-test ; perl mysql-test-run.pl  
  36.   
  37. Please report any problems with the /usr/bin/mysqlbug script!  
  38.   
  39.                                                            [  OK  ]  
  40. Starting mysqld:                                           [  OK  ]  

4、为MariaDB设置密码

[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. # /usr/bin/mysqladmin -u root password 'adminadmin'  

登陆MariaDB
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. MySQL [(none)]> use mysql;  
  2. MySQL [mysql]> update user set host='%' where user='root' and host='127.0.0.1';  
  3. MySQL [mysql]> grant all privileges on *.* to 'root'@'%' identified by 'adminadmin' with grant option;  
  4. MySQL [mysql]> flush privileges;  

5、让防火墙通过3306端口
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. # vi /etc/sysconfig/iptables  

添加如下内容:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT  

保存并退出编辑
重启防火墙服务
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
  1. # service iptables restart  

远程连接检查,一切OK!
0 0