quarta-feira, 20 de julho de 2016

Criar usuário no MySql

Para criar um novo usuário no MySql proceda da seguinte forma:

- Faça o acesso a área do MySql.

$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 43
Server version: 5.5.49-0+deb8u1 (Debian)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

- Agora pelo shell do MySql vamos criar o novo usuário.

mysql> CREATE USER 'novousuario'@'localhost' IDENTIFIED BY 'pass';
Query OK, 0 rows affected (0.00 sec)

- Vamos dar permissão total ao novo usuário.

mysql> GRANT ALL PRIVILEGES ON * . * TO 'novousuario'@'localhost';
Query OK, 0 rows affected (0.00 sec)

- Pronto, agora é só carregar os privilégios do novo usuário.

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

Repita o processo para o mesmo usuário para caso ele precise acessar remotamente a base. Para isso use 'novousuario'@'%' no lugar de 'novousuario'@'localhost'.

Nenhum comentário:

Postar um comentário