ares# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 64 Server version: tha_duh_version_0.1 Copyright (c) 2000, 2011, 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 database foo_db; Query OK, 1 row affected (0.00 sec) mysql> grant all on foo_db.* to foo_db_user; Query OK, 0 rows affected (0.00 sec) mysql> set password for foo_db_user = password('foo_db_user_passwd'); Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
To see all granted privileges for a user easily.
mysql> show grants for foo_db_user; +------------------------------------------------------------------------------------------------------------+ | Grants for foo_db_user@% | +------------------------------------------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO 'foo_db_user'@'%' IDENTIFIED BY PASSWORD '*6C0EECAB4C3A82BB5678B5915C318891D2264AAD' | | GRANT ALL PRIVILEGES ON `foo_db`.* TO 'foo_db_user'@'%' | +------------------------------------------------------------------------------------------------------------+ 2 rows in set (0.00 sec) mysql> quit Bye
To enable remote logins for the foo_db_user
grant all on foo_db.* to 'foo_db_user'@'192.0.2.13' IDENTIFIED BY 'password';where 192.0.2.13 is the IP address that foo_db_user connects from. You may use % if you need to allow access to foo_db_user from everywhere.
some φ@\<3n5td hm! thorough ref mysql add users
mysql add user