I just started learning MySQL today. I am the first to contact user management.Note: the command in MySQL can be case-sensitive =========== logon and exit ==================
Root @ jack-desktop :~ # Mysql-uroot-pzengdc123 // the space between-U and root is dispensable, and the space between-P and password cannot be root @ jack-desktop :~ # Mysql-u root-pzengdc123 root @ jack-desktop :~ # Mysql-uroot-penter password: mysql> exit // exit command
In addition, the exit command is mysql> quit or \ Q. in Linux, you can press Ctrl + D to interrupt the connection.
============================================================== Mysqladmin-u root Password ab12
Note: because the root account does not have a password at the beginning,-P can be omitted.
Change the root password to 123456.-P either does not add the original password, or keeps up with the original password. No space is allowed. Otherwise, an error will occur.
Root @ jack-desktop: webservice_src # mysqladmin-u root-P password 123456 enter password: // enter the original password. If it is null, press ENTER root @ jack-desktop: webservice_src # root @ jack-desktop: webservice_src # mysqladmin-u root-P zengdc123 password 123456 enter password: mysqladmin: Unknown command: 'zengdc123 'root @ jack-desktop: webservice_src # mysqladmin-u root-pzengdc123 password 123456
Modify the user password in the MySQL statement
mysql> update mysql.user set password=password('jk110333') where user="siasjack" and host="localhost";Query OK, 1 row affected (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 0
======================== Add User ======================================= database Permissions queries available, insert, modify, delete, the corresponding command is select, insert, update, delete, full permission can also be replaced by all
Mysql> grant all on *. * To jk110333 @ ''identified by "123"; // query all permissions OK, 0 rows affected (0.00 Sec) mysql> grant select on monitor_db. * To siasjack @ 'localhost' identified by "123"; // only the query permission is available. You can only log on to query OK on localhost, 0 rows affected (0.00 sec)
After adding a user, you must refresh the permission table of the system.
mysql>flush privileges;
==================== Delete a user =============================
Mysql> Delete from MySQL. user where user = "siasjack" and host = "localhost"; query OK, 1 row affected (0.00 Sec) mysql> Delete from MySQL. user where user = "jk110333"; query OK, 1 row affected (0.00 Sec) mysql> flush privileges // refresh the system permission table. ->; Query OK, 0 rows affected (0.00 Sec) mysql>