3 月 092016
 

增加软件源

/etc/yum.repos.d/MariaDB.repo

配置文件示例如下,可根据YUM源目录中版本及系统进行修改

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

配置路径


执行安装

yum install MariaDB-server MariaDB-client

3 月 082016
 

使用PuTTY Key Generator生成SSH密钥对,并将私钥保存为.ppk文件

查看当前用户目录,建立ssh密钥存储目录

建立公钥认证存储文件,并复制PuTTY Keygen生成的公钥

[root@localhost ~]# vi .ssh/authorized_keys

修改密钥存储目录和文件的属性为600

确保系统SELinux已关闭

使用Putty登录系统,输入服务器IP地址

修改SSH认证类型设置,选择已保存的私钥文件后点击Open开始连接

提示输入用户名

成功登录进入系统,并显示采用注释为公钥进行认证

2 月 262016
 

设置管理用户

[root@localhost ~]# mongo
MongoDB shell version: 2.4.14
connecting to: test
> use admin
switched to db admin
> db.addUser("admin","123456")
{
 "user" : "admin",
 "readOnly" : false,
 "pwd" : "95ec4261124ba5951720b199908d892b",
 "_id" : ObjectId("5764ab3203036a2746eb64de")
}
> exit
bye
[root@localhost ~]#

启用安全认证并重启服务

[root@localhost ~]# vi /etc/mongodb.conf
# Turn on/off security. Off is currently the default
#noauth = true
#auth = true
auth = true

[root@localhost ~]# service mongod restart
Stopping mongod: [ OK ]
Starting mongod: [ OK ]
[root@localhost ~]#

登录管理数据库并认证

> use admin
switched to db admin
> db.auth("admin","123456")
1
>

> use linuxcache
switched to db linuxcache
> db.addUser("harvey","12345678")
{
 "user" : "harvey",
 "readOnly" : false,
 "pwd" : "a3e0f380ad93c10d8e2561cb0442bc4f",
 "_id" : ObjectId("5764aceb2b5adef8e142afc4")
}
>

查看当前使用数据库

> db
linuxcache
>

查看当前数据库用户

> show users
{
 "_id" : ObjectId("5764aceb2b5adef8e142afc4"),
 "user" : "harvey",
 "readOnly" : false,
 "pwd" : "a3e0f380ad93c10d8e2561cb0442bc4f"
}
>

添加一个只读用户

> use linuxcache
switched to db linuxcache
> db.addUser("tom","123","true")
{
 "user" : "tom",
 "readOnly" : "true",
 "pwd" : "4441076092a2c8a4171c33ac937a4861",
 "_id" : ObjectId("5764add92b5adef8e142afc5")
}
>

> show users
{
 "_id" : ObjectId("5764aceb2b5adef8e142afc4"),
 "pwd" : "5021efc96881624a47ab89a0bc1fde9b",
 "readOnly" : false,
 "user" : "harvey"
}
{
 "_id" : ObjectId("5764add92b5adef8e142afc5"),
 "user" : "tom",
 "readOnly" : "true",
 "pwd" : "4441076092a2c8a4171c33ac937a4861"
}
>

修改用户密码

> use linuxcache
switched to db linuxcache
> db.auth("harvey","12345678")
1
> db.changeUserPassword("harvey","87654321")
>