Mariadb10 rpm 包安装

MariaDB  下载:https://mirrors.shu.edu.cn/mariadb//mariadb-10.3.8/yum/

MariaDB 10.3.8 的安装:

[root@oc01 mariadb]# rpm -ivh boost-program-options-1.53.0-27.el7.x86_64.rpm

warning: boost-program-options-1.53.0-27.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

  1:boost-program-options-1.53.0-27.e################################# [100%]

[root@oc01 mariadb]#

[root@oc01 mariadb]#

[root@oc01 mariadb]# rpm -ivh galera-25.3.23-1.rhel7.el7.centos.x86_64.rpm

warning: galera-25.3.23-1.rhel7.el7.centos.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

  1:galera-25.3.23-1.rhel7.el7.centos################################# [100%]


[root@oc01 mariadb]# rpm -ivh MariaDB-10.3.8-centos73-x86_64-compat.rpm MariaDB-10.3.8-centos73-x86_64-common.rpm      //compat,common 需要一起安装,否则会报错相互依赖

warning: MariaDB-10.3.8-centos73-x86_64-compat.rpm: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

  1:MariaDB-common-10.3.8-1.el7.cento################################# [ 50%]

  2:MariaDB-compat-10.3.8-1.el7.cento################################# [100%]

[root@oc01 mariadb]#

[root@oc01 mariadb]#

[root@oc01 mariadb]# rpm -ivh MariaDB-10.3.8-centos73-x86_64-devel.rpm

warning: MariaDB-10.3.8-centos73-x86_64-devel.rpm: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

  1:MariaDB-devel-10.3.8-1.el7.centos################################# [100%]

[root@oc01 mariadb]# rpm -ivh MariaDB-10.3.8-centos73-x86_64-client.rpm

warning: MariaDB-10.3.8-centos73-x86_64-client.rpm: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

  1:MariaDB-client-10.3.8-1.el7.cento################################# [100%]

[root@oc01 mariadb]#

[root@oc01 mariadb]# rpm -ivh MariaDB-10.3.8-centos73-x86_64-server.rpm

warning: MariaDB-10.3.8-centos73-x86_64-server.rpm: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

  1:MariaDB-server-10.3.8-1.el7.cento################################# [100%]

chown: invalid user: ?.ysql?

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 oc01 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/

root@oc01 ~]# systemctl start mariadb

[root@oc01 ~]# systemctl enable mariadb

ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'

在确认MariaDB数据库软件程序安装完毕并成功启动后请不要立即使用。为了确保数据库的安全性和正常运转,需要先对数据库程序进行初始化操作。

[root@oc01 ~]# mysql_secure_installation

/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

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:输入要为root管理员设置的数据库密码

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(禁止root管理员从远程登录)

... 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(删除test数据库并取消对它的访问权限)

- 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!

如果需要让root管理员远程访问数据库,可在上面的初始化操作中设置策略,以允许root管理员从远程访问。

设置防火墙,使其放行对数据库服务程序的访问请求,数据库服务程序默认会占用3306端口,在防火墙策略中服务名称统一叫作mysql:

[root@oc01 ~]# firewall-cmd --permanent --add-service=mysql

success

[root@oc01 ~]# firewall-cmd --reload

success

现在我们将首次登录MariaDB数据库。

MariaDB [(none)]> SET password = PASSWORD('oc01');

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit

Bye

[root@oc01 ~]# mysql -u root -p

Enter password:此处输入root管理员在数据库中的新密码

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

 管理用户以及授权

使用root管理员登录数据库管理系统,然后按照“CREATE USER 用户名@主机名 IDENTIFIED BY '密码'; ”的格式创建数据库管理账户。

MariaDB [(none)]> CREATE USER ambari@localhost IDENTIFIED BY 'ambari';

Query OK, 0 rows affected (0.00 sec)

创建的账户信息可以使用select命令语句来查询。

MariaDB [(none)]> use mysql

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

MariaDB [mysql]> SELECT HOST,USER,PASSWORD FROM user WHERE USER="ambari";

+-----------+------+-------------------------------------------+

| host      | user  | password                                  |

+-----------+------+-------------------------------------------+

| localhost | ambari | *55D9962586BE75F4B7D421E6655973DB07D6869F |

+-----------+------+-------------------------------------------+

MariaDB [mysql]> GRANT SELECT,UPDATE,DELETE,INSERT ON mysql.user TO ambari@localhost;

Query OK, 0 rows affected (0.00 sec)

在执行完上述授权操作之后,我们再查看一下账户ambari的权限:

MariaDB [(none)]>  SHOW GRANTS FOR ambari@localhost;

+-------------------------------------------------------------------------------------------------------------+

| Grants for ambari@localhost |

+-------------------------------------------------------------------------------------------------------------+

| GRANT USAGE ON *.* TO 'ambari'@'localhost' IDENTIFIED BY PASSWORD '*55D9962586BE75F4B7D421E6655973DB07D6869F' |

| GRANT SELECT, INSERT, UPDATE, DELETE ON `mysql`.`user` TO 'ambari'@'localhost' |

+-------------------------------------------------------------------------------------------------------------+

2 rows in set (0.00 sec)


GRANT 权限 ON 数据库.表单名称 TO 用户名@主机名 对某个特定数据库中的特定表单给予授权

GRANT 权限 ON 数据库.* TO 用户名@主机名 对某个特定数据库中的所有表单给予授权

GRANT 权限 ON *.* TO 用户名@主机名 对所有数据库及所有表单给予授权

GRANT 权限1,权限2 ON 数据库.* TO 用户名@主机名 对某个数据库中的所有表单给予多个授权

GRANT ALL PRIVILEGES ON *.* TO 用户名@主机名 对所有数据库及所有表单给予全部授权(需谨慎操作)


如果需要回收分配的权限可用revoke操作,除了移除授权的命令(revoke)与授权命令(grant)不同之外,其余部分都是一致的。

MariaDB [(none)]> REVOKE SELECT,UPDATE,DELETE,INSERT ON mysql.user FROM ambari@localhost;

Query OK, 0 rows affected (0.00 sec)

可以看到,除了移除授权的命令(revoke)与授权命令(grant)不同之外,其余部分都是一致的。这不仅好记而且也容易理解。执行移除授权命令后,再来查看账户luke的信息:

MariaDB [(none)]> SHOW GRANTS FOR ambari@localhost;

+-------------------------------------------------------------------------------------------------------------+

| Grants for ambari@localhost |

+-------------------------------------------------------------------------------------------------------------+

| GRANT USAGE ON *.* TO 'ambari'@'localhost' IDENTIFIED BY PASSWORD '*55D9962586BE75F4B7D421E6655973DB07D6869F' |

+-------------------------------------------------------------------------------------------------------------+

1 row in set (0.00 sec)

你可能感兴趣的:(Mariadb10 rpm 包安装)