Mysql basics: log on and exit, change the user password, and add and delete user _ MySQL

Source: Internet
Author: User
Tags mysql commands
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.