Apple - How to create new mysql user/db in Mac OS X?

If you are using the terminal client, generally you can do things like reset the root users password for mysql or create databases. A simple example can be found at the MySQL docs site, of which I will copy the highlights.

To create a new MySQL user:

  • Login to MySQL in Terminal:mysql -u username

  • In the prompt:CREATE USER 'admin'@'localhost'; GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost';

  • If you want to create a database: create database name; is all you need to do

If you do decide to use mysqladmin, mysqladmin can create and drop databases, but it cannot create new users.


You can use a GUI client, like Sequel Pro.


Thanks everyone. I used the below commands to figure it out.

Sarbbottam-Bandyopadhyays-MacBook-Pro:bin sarbbottam$ mysql -u root
mysql> create database tutorialdb;
mysql> create user 'tutorialuser'@'localhost' identified by 'tutorialuser';
mysql> grant all on tutorialdb.* to 'tutorialuser'@'localhost';
mysql> exit
Bye

Sarbbottam-Bandyopadhyays-MacBook-Pro:bin sarbbottam$ mysql -u tutorialuser -p
Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1532
Server version: 5.5.9 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, 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>