Mysql basics: log on and exit, change the user password, add or delete users, learn mysql at the beginning of today, first contact user management, share with you the bet: mysql commands can be case sensitive
============ Logon and exit ========================== [SQL] 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-p Enter 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
[sql] 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
[SQL] 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.
[SQL] mysql> flush privileges; ==================== delete a user ================================ [SQL] 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>