mysql Adding users and assigning access rights
mysql> create user 'user1'@'locahost'
identified by 'password';
mysql> select user,host from
mysql.user;
+------------------+-----------+
| user
| host |
+------------------+-----------+
| root
| 127.0.0.1 |
| root
| ::1 |
| user1
| locahost |
| debian-sys-maint | localhost |
| root
| localhost |
| root
| ubuntu |
+------------------+-----------+
6 rows in set (0.00 sec)
mysql> grant all privileges on *.* to
'user1'@'localhost' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> show grants for
'user1'@'localhost';
+----------------------------------------------------------------------+
| Grants for user1@localhost
|
+----------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO
'user1'@'localhost' WITH GRANT OPTION |
+----------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> update mysql.user set
password=PASSWORD('qweqwe_1');
Query OK, 6 rows affected (0.01 sec)
Rows matched: 8 Changed: 6 Warnings:
0
ysql> select version();
+-------------------------+
| version()
|
+-------------------------+
| 5.5.53-0ubuntu0.14.04.1 |
+-------------------------+
1 row in set (0.01 sec)
mysql> show variables;
SHOW VARIABLES LIKE "%version%";
mysql> select @@log;
+-------+
| @@log |
+-------+
| 0 |
+-------+
1 row in set (0.00 sec)
To limit privileges to certain tasks, mention specific privileges in a
grant statement:mysql> grant select, insert, update, delete, create -> on dbname.* to ‘dbuser’@’localhost’;
The preceding statement will
grant select, insert, update, delete, and create privileges on any table under the dbname database.
Similar to preceding add user example, other user management tasks can be performed with SQL queries as follows:
mysql> drop user ‘dbuser’@’localhost’;
- MySQL user account management at https://dev.mysql.com/doc/refman/5.6/en/user-account-management.html
Comments
Post a Comment