Can any one please let me know how to create new user and new db in MySQL? How to use mysqladmin in Mac OS X?
Asked
Active
Viewed 1.2e+01k times
9
-
Would you consider editing this question to make it more relevant to Mac OS X? General beginner mysql questions might get better answers at Stack Overflow. Also do read the FAQ so you are less likely to ask questions that read like "what book can I study to learn mysql on mac?" Cheers and welcome nevertheless! – bmike Apr 18 '11 at 19:01
5 Answers
13
If you are using the terminal client, generally you can do things like reset the root users password for mysql or create databases.
To create a new MySQL user:
Login to MySQL in Terminal:
mysql -u usernameIn 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.
ConstantineK
- 5,622
- 1
- 18
- 23
-
-
Apologies but it looks like that's going to be permanent, they no longer appear to have a selfsame site. – ConstantineK Jul 25 '22 at 15:39
2
You can use a GUI client, like Sequel Pro.
Davide Gualano
- 804
- 2
- 12
- 21
-
This is a bad answer - you should at least tell people how to do it with the program you're suggesting – The Onin Jan 28 '18 at 05:44
2
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>
nohillside
- 92,308
- 39
- 198
- 242
Sarbbottam Bandyopadhyay
- 277
- 1
- 3
- 10
0
Try, introduce complete path to mysql:
Go to Terminal:
$ /usr/local/mysql/bin/mysql -u user
I hope help you!
-
On a vanilla system this will lead to `-bash: /usr/local/mysql/bin/mysql: No such file or directory-bash: /usr/local/mysql/bin/mysqlx: No such file or directory` – nohillside Sep 07 '16 at 17:08
-
-
Yes. On a standard OS X installation, there is no `mysql` in `/usr/local`. – nohillside Sep 07 '16 at 17:16
-
Please It's work for me. Check this https://coolestguidesontheplanet.com/start-stop-mysql-from-the-command-line-terminal-osx-linux/ – Jose Carlos Ramos Carmenates Sep 07 '16 at 17:33
-
I'm sure it does, *after* a manual installation of MySQL (which is the part missing in your answer) – nohillside Sep 07 '16 at 17:44
