Saturday, June 27, 2015

Create Window Native Authentication MySQL Users

Ensure following plugin has been loaded via my.ini:

# Enable Windows Authentication
plugin-load=authentication_windows.dll

Create MySQL Users
C:\Users\Administrator>mysql -u donghua -p
Enter password: ********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 25
Server version: 5.6.25-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced Edition (Commercial)

Copyright (c) 2000, 2015, 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> CREATE USER Administrator
    ->   IDENTIFIED WITH authentication_windows
    ->   AS 'Administrators';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all on *.* to Administrator@'%';
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

Verify MySQL Users

C:\Users\Administrator>mysql --user=Administrator
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 28
Server version: 5.6.25-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced Edition (Commercial)

Copyright (c) 2000, 2015, 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> select current_user();
+-----------------+
| current_user()  |
+-----------------+
| Administrator@% |
+-----------------+
1 row in set (0.00 sec)


mysql>