向 mariadb 用户授予创建数据库权限

grant create database privilege to mariadb user(向 mariadb 用户授予创建数据库权限)

本文介绍了向 mariadb 用户授予创建数据库权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在数据库管理中,使用 root 用户是一种不好的行为,我正在设置一个具有基本权限的自定义用户(创建数据库、删除数据库、对所有新创建的数据库的所有访问权限等).
我创建了一个用户 antoine,它应该是用于登录 mariadb 服务器 的基本用户.

I know that in database management, it's a bad behavior to use the root user and I'm setting up a custom user with base privileges (create database, drop db, all access to all newly created dbs, etc).
I've created a user antoine which should be the base user used to login to the mariadb server.

问题是,我不知道如何授予管理权限,如 create database xxxdrop database xxx 等...文档解释说授予一个特权,你运行以下命令:

Problem is, I can't figure out how to grant administration privileges like create database xxx, drop database xxx, etc... The documentation explains that to grant a privilege, you run the following command:

GRANT role ON database.table TO user@host

但是,当涉及到服务器权限时,我该怎么做呢?我试过 *.* 而不是 database.table 但它不起作用.

But, when it comes to server privileges, how can I do it ? I've tried the *.* instead of database.table but it's not working.

推荐答案

创建一个用户,然后授予该用户您希望他们拥有的权限.

Create a user and then grant that user the privileges you want them to have like this.

CREATE USER 'antoine'@'localhost' IDENTIFIED VIA mysql_native_password USING 'a-password';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON *.* TO 'antoine'@'localhost'; 

这篇关于向 mariadb 用户授予创建数据库权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:向 mariadb 用户授予创建数据库权限

基础教程推荐