Category: ‘MySQL’

Create MySQL User

January 2, 2012 Posted by admin

Generate hash for MySQL database user’s password if old_passwords=0:

mysql> SELECT PASSWORD('testpass');
+-------------------------------------------+
| PASSWORD('testpass') |
+-------------------------------------------+
| *00E247AC5F9AF26AE0194B41E1E769DEE1429A29 |
+-------------------------------------------+
1 row in set (0.00 sec)

Generate hash for MySQL database user’s password if old_passwords=1:

mysql> SELECT OLD_PASSWORD('testpass');
+--------------------------+
| OLD_PASSWORD('testpass') |
+--------------------------+
| 7dcda0d57290b453 |
+--------------------------+
1 row in set (0.00 sec)

Create User

CREATE USER 'testuser'@'localhost' IDENTIFIED BY '';
GRANT ALL PRIVILEGES ON dbname.* TO 'testuser'@'localhost';