Mysql basics: log on and exit, change the user password, and add or delete users. now I am learning mysql, and I am the first to contact user management.
Note: 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 include query, insert, modify, and delete. corresponding commands include select, insert, update, and delete. full permissions 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>
Address: http://blog.csdn.net/jk110333/article/details/9312201