Mysql Create a database for a single user

2

I want to create a database where only one user can access the information. Although there are already users created on the server, but only the user I create has to be the only one to have access to a particular database. I'm just getting the reverse "create user for a single database". I am using this syntax to create the database, the user and their permission:

CREATE DATABASE test
  DEFAULT CHARACTER SET utf8
  DEFAULT COLLATE utf8_general_ci;

CREATE USER 'root'@'%' IDENTIFIED BY 'testing';
 GRANT ALL ON test.* TO 'root'@'%' WITH GRANT OPTION;

FLUSH PRIVILEGES;
    
asked by anonymous 16.12.2016 / 11:08

1 answer

0

An example CREATE USER 'usuario'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON * . * TO 'usuario'@'localhost';

After assigning everything, run the command FLUSH PRIVILEGES; to reload privileges

If only one must have access permission, you can revoke the privileges of others or delete others as they will not have access

REVOKE [tipo de permissão] ON [nome da base de dados].[nome da tabela] FROM ‘[nome do usuário]’@‘localhost’;

or

DROP USER ‘demo’@‘localhost’;

    
10.01.2017 / 14:56