After logging in to the MySQL server, you can use the grant command to create a user and assign permissions.
mysql>for-adatabase changedmysql> GRANT select,insert,update,delete , Create,drop -on MySQL -to [email protected]0 rows affected, 1 warning (0.11 sec )
The above command creates a user information record in the MySQL database. a semicolon (;) indicates that the instruction has been edited and ready to execute.
You can then see whether the new user exists by using the following command.
Mysql> Select User, host,authentication_string from User;+------------------+-----------+-------------------------------------------+| User |Host|Authentication_string|+------------------+-----------+-------------------------------------------+|Root|localhost| *74ed8dce9b1b4b780e427473ddd66f8be6398e8e||Mysql.sys|localhost| *Thisisnotavalidpasswordthatcanbeusedhere||Debian-Sys-Maint|localhost| *0e2901479c3b89118b95a2622b7f895dfc60c4a0||Zara|localhost| *08f7d6c84224646b57bdf66a6480f337f403f10c||Firstuser|localhost| *2470c0c06dee42fd1618bb99005adca2ec9d1e19||Rick|localhost| *35eb40c575cd0daa851919e0e3e28c0718879407|+------------------+-----------+-------------------------------------------+6Rowsinch Set(0.00Sec
As you can see, a new user is already present and you are logged in as a user.
Note: The password entry for the user table in MySQL5.7 has been replaced with authentication_string
Mysql>\qbyedeamon@deamon-h55m-S2:~$ mysql-U firstuser-penter password:welcome toThe MySQL Monitor. CommandsEnd with;or\g.your MySQL Connection ID is TenServer Version:5.7. --0ubuntu0.16.04.1(Ubuntu) Copyright (c) -, ., Oracleand/orits affiliates. Allrights reserved. Oracle isA registered trademark ofOracle Corporationand/oritsaffiliates. Names may trademarks oftheir respectiveowners. Type'Help ;' or '\h' forHelp. Type'\c' toClear the Currentinput Statement.mysql>
3.MYSQL Create new user