Mariadb10 安装方式(rpm)

一。 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)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,547评论 6 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,399评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,428评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,599评论 1 274
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,612评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,577评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,941评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,603评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,852评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,605评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,693评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,375评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,955评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,936评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,172评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,970评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,414评论 2 342

推荐阅读更多精彩内容