After installing MySQL
server, you need an account to communicate with MySQL server. Following steps
explains you, how to create user account and grant permissions.
$ mysql -h localhost -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 Server version: 5.7.13 Homebrew Copyright (c) 2000, 2016, 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 'krishna'@'localhost' IDENTIFIED BY 'krishna'; Query OK, 0 rows affected (0.00 sec) mysql> GRANT ALL ON sample.* TO 'krishna'@'localhost'; Query OK, 0 rows affected (0.00 sec) mysql> quit Bye
Now try to login as
user krishna using the command ‘mysql -h localhost -u krishna -p’. It prompts
for password, enter ‘krishna’ as password.
$ mysql -h localhost -u krishna -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.7.13 Homebrew Copyright (c) 2000, 2016, 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>
No comments:
Post a Comment