RedHat Enterprise Linux 7.3下安装MariaDB 10.2

   首先在 RHEL操作系统中添加 MariaDB 的 YUM 配置文件 MariaDB.repo 文件。
# vi /etc/yum.repos.d/MariaDB.repo
   添加如下内容:
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/rhel7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
   运行yum update更新相应的资源文件:
# yum update
已加载插件:fastestmirror, langpacks, product-id, search-disabled-repos, subscription-
          : manager
This system is not registered with Subscription Management. You can use subscription-manager to register.
base                                                     | 3.6 kB     00:00     
extras                                                   | 3.4 kB     00:00     
mariadb                                                  | 2.9 kB     00:00     
updates                                                  | 3.4 kB     00:00     
mariadb/primary_db                                         |  20 kB   00:00     
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 MariaDB-compat.x86_64.0.10.2.6-1.el7.centos 将被 舍弃
--> 正在处理依赖关系 MariaDB-common,它被软件包 MariaDB-compat-10.2.6-1.el7.centos.x86_64 需要
---> 软件包 mariadb-libs.x86_64.1.5.5.52-1.el7 将被 取代
--> 正在检查事务
---> 软件包 MariaDB-common.x86_64.0.10.2.6-1.el7.centos 将被 安装
--> 解决依赖关系完成

依赖关系解决

================================================================================
 Package             架构        版本                        源            大小
================================================================================
正在安装:
 MariaDB-compat      x86_64      10.2.6-1.el7.centos         mariadb      2.8 M
      替换  mariadb-libs.x86_64 1:5.5.52-1.el7
为依赖而安装:
 MariaDB-common      x86_64      10.2.6-1.el7.centos         mariadb      197 k

事务概要
================================================================================
安装  1 软件包 (+1 依赖软件包)

总下载量:3.0 M
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/$releasever/mariadb/packages/MariaDB-10.2.6-centos7-x86_64-common.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 1bb943db: NOKEY
MariaDB-10.2.6-centos7-x86_64-common.rpm 的公钥尚未安装
(1/2): MariaDB-10.2.6-centos7-x86_64-common.rpm            | 197 kB   00:01     
(2/2): MariaDB-10.2.6-centos7-x86_64-compat.rpm            | 2.8 MB   00:03     
--------------------------------------------------------------------------------
总计                                               773 kB/s | 3.0 MB  00:04     
从 https://yum.mariadb.org/RPM-GPG-KEY-MariaDB 检索密钥
导入 GPG key 0x1BB943DB:
 用户ID     : "MariaDB Package Signing Key <package-signing-key@mariadb.org>"
 指纹       : 1993 69e5 404b d5fc 7d2f e43b cbcb 082a 1bb9 43db
 来自       : https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : MariaDB-common-10.2.6-1.el7.centos.x86_64                   1/3 
  正在安装    : MariaDB-compat-10.2.6-1.el7.centos.x86_64                   2/3 
  正在删除    : 1:mariadb-libs-5.5.52-1.el7.x86_64                          3/3 
  验证中      : MariaDB-compat-10.2.6-1.el7.centos.x86_64                   1/3 
  验证中      : MariaDB-common-10.2.6-1.el7.centos.x86_64                   2/3 
  验证中      : 1:mariadb-libs-5.5.52-1.el7.x86_64                          3/3 

已安装:
  MariaDB-compat.x86_64 0:10.2.6-1.el7.centos                                   

作为依赖被安装:
  MariaDB-common.x86_64 0:10.2.6-1.el7.centos                                   

替代:
  mariadb-libs.x86_64 1:5.5.52-1.el7                                            

完毕!
   运行yum install mariadb-server mariadb  安装 mariadb server 及 client
yum install mariadb-server mariadb  
已加载插件:fastestmirror, langpacks, product-id, search-disabled-repos, subscription-
          : manager
This system is not registered with Subscription Management. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
软件包 mariadb-server 已经被 MariaDB-server 取代,改为尝试安装 MariaDB-server-10.2.6-1.el7.centos.x86_64
软件包 mariadb 已经被 MariaDB-client 取代,改为尝试安装 MariaDB-client-10.2.6-1.el7.centos.x86_64
正在解决依赖关系
--> 正在检查事务
---> 软件包 MariaDB-client.x86_64.0.10.2.6-1.el7.centos 将被 安装
---> 软件包 MariaDB-server.x86_64.0.10.2.6-1.el7.centos 将被 安装
--> 正在处理依赖关系 galera,它被软件包 MariaDB-server-10.2.6-1.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 galera.x86_64.0.25.3.20-1.rhel7.el7.centos 将被 安装
--> 正在处理依赖关系 libboost_program_options.so.1.53.0()(64bit),它被软件包 galera-25.3.20-1.rhel7.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 boost-program-options.x86_64.0.1.53.0-26.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

================================================================================
 Package                 架构     版本                          源         大小
================================================================================
正在安装:
 MariaDB-client          x86_64   10.2.6-1.el7.centos           mariadb    48 M
 MariaDB-server          x86_64   10.2.6-1.el7.centos           mariadb   108 M
为依赖而安装:
 boost-program-options   x86_64   1.53.0-26.el7                 base      156 k
 galera                  x86_64   25.3.20-1.rhel7.el7.centos    mariadb   8.0 M

事务概要
================================================================================
安装  2 软件包 (+2 依赖软件包)

总下载量:164 M
安装大小:695 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): boost-program-options-1.53.0-26.el7.x86_64.rpm      | 156 kB   00:00     
(2/4): MariaDB-10.2.6-centos7-x86_64-client.rpm            |  48 MB   00:26     
(3/4): galera-25.3.20-1.rhel7.el7.centos.x86_64.rpm        | 8.0 MB   00:07     
(4/4): MariaDB-10.2.6-centos7-x86_64-server.rpm            | 108 MB   00:49     
--------------------------------------------------------------------------------
总计                                               3.3 MB/s | 164 MB  00:49     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : MariaDB-client-10.2.6-1.el7.centos.x86_64                   1/4 
  正在安装    : boost-program-options-1.53.0-26.el7.x86_64                  2/4 
  正在安装    : galera-25.3.20-1.rhel7.el7.centos.x86_64                    3/4 
  正在安装    : MariaDB-server-10.2.6-1.el7.centos.x86_64                   4/4 
chown: 无效的用户: "mysql"

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB 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 localhost.localdomain password 'new-password'

Alternatively you can run:
'/usr/bin/mysql_secure_installation'

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

  验证中      : galera-25.3.20-1.rhel7.el7.centos.x86_64                    1/4 
  验证中      : MariaDB-server-10.2.6-1.el7.centos.x86_64                   2/4 
  验证中      : boost-program-options-1.53.0-26.el7.x86_64                  3/4 
  验证中      : MariaDB-client-10.2.6-1.el7.centos.x86_64                   4/4 

已安装:
  MariaDB-client.x86_64 0:10.2.6-1.el7.centos                                   
  MariaDB-server.x86_64 0:10.2.6-1.el7.centos                                   

作为依赖被安装:
  boost-program-options.x86_64 0:1.53.0-26.el7                                  
  galera.x86_64 0:25.3.20-1.rhel7.el7.centos                                    

完毕!
   开启mariadb服务。
systemctl start mariadb.service 
   设为开机启动:
systemctl enable mariadb.service 
   MariaDB Server 预设 root 密码为空密码, 要重设 root 密码,安装MariaDB时候有如下提示:
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB 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 localhost.localdomain password 'new-password'

Alternatively you can run:
'/usr/bin/mysql_secure_installation'
    可以按照上面的提示进行密码的修改。
    mysql_secure_installation可用来修改密码, 这个方法只要在指令模式输入 mysql_secure_installation, 跟著步骤回答问题就可以。以下会看看登入 mysql 修改密码。
mysql -u root  
   然后会看到类似 “MariaDB [(none)]>”, 输入以下指令修改:
    use mysql;  
    update user set password=PASSWORD(“new_password”) where User=’root’;  
    flush privileges;  
    quit  
   上面的 new_password 请改为你想修改的密码, 这样就已经修改完成了。
mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, 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 MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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] Y
 ... Success!

By default, MariaDB 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!

Cleaning up...

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

Thanks for using MariaDB!
   查看MariaDB的版本号:
mysql -V
mysql  Ver 15.1 Distrib 10.2.6-MariaDB, for Linux (x86_64) using readline 5.1
   查看MariaDB的状态:
systemctl status mariadb
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: active (running) since 三 2017-06-07 09:45:51 CST; 7min ago
 Main PID: 4024 (mysqld)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/mariadb.service
           └─4024 /usr/sbin/mysqld

6月 07 09:45:51 localhost.localdomain mysqld[4024]: 2017-06-07  9:45:51 1406...
6月 07 09:45:51 localhost.localdomain mysqld[4024]: 2017-06-07  9:45:51 1406...
6月 07 09:45:51 localhost.localdomain mysqld[4024]: 2017-06-07  9:45:51 1406...
6月 07 09:45:51 localhost.localdomain mysqld[4024]: 2017-06-07  9:45:51 1406...
6月 07 09:45:51 localhost.localdomain mysqld[4024]: 2017-06-07  9:45:51 1406...
6月 07 09:45:51 localhost.localdomain mysqld[4024]: 2017-06-07  9:45:51 1406...
6月 07 09:45:51 localhost.localdomain mysqld[4024]: 2017-06-07  9:45:51 1406...
6月 07 09:45:51 localhost.localdomain mysqld[4024]: 2017-06-07  9:45:51 1406...
6月 07 09:45:51 localhost.localdomain mysqld[4024]: Version: '10.2.6-MariaDB...
6月 07 09:45:51 localhost.localdomain systemd[1]: Started MariaDB database s...
Hint: Some lines were ellipsized, use -l to show in full.
   在/etc/my.cnf中的[mysqld]后添加添加lower_case_table_names=1,重启MYSQL服务,这时已设置成功。其中 0:区分大小写,1:不区分大小写;
   查看配置文件信息:
cat /etc/my.cnf
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d


[root@localhost my.cnf.d]# ls
enable_encryption.preset  mysql-clients.cnf  server.cnf
   设置MariaDB的编码为utf8,在server.cnf的server下面添加以下语句。
   default-character-set =utf8

   远程连接设置
把在所有数据库的所有表的所有权限赋值给位于所有IP地址的root用户。

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

如果是新用户而不是root,则要先新建用户

mysql>create user 'username'@'%' identified by 'password';  

此时就可以进行远程连接了。
   至此,MariaDB安装配置完毕。
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值