MySQL user management, common SQL statements, MySQL database backup recovery

Source: Internet
Author: User

13.4 MySQL User management
    • Create a user and authorize
[[email protected] ~]# mysql -uroot -p‘taoyuan‘  //登录mysql> grant all on *.* to ‘user1‘@‘172.0.0.1‘ identified by ‘123456‘;#创建user用户并授予其所有权限“*.*”(通配符)#第一个*表示db_name;第二个*表示tb_name#同时指定其来源IP127.0.0.1(即,只可通过此IP登录)#此处可以使用通配符%,代表所有IP(一般不使用)#identified by :设定密码#quit 退出[[email protected] ~]# mysql -uuser1 -p123456 -h127.0.0.1

Sign in with a socket

#登录root用户mysql> grant all on *.* to ‘user1‘@‘localhost‘ identified by ‘123456‘;Query OK, 0 rows affected (0.01 sec)#授权localhost#登录[[email protected] ~]# mysql -uuser1 -p123456

Note: because the specified login host is localhost, the user uses the local mysql.socket file by default (listening) and does not need to specify an IP to log on.

    • Authorization for specific permissions
[[email protected] ~]# mysql -urootmysql> show grants;#查看当前用户的权限mysql> show grants for [email protected]‘127.0.0.1‘;#查看指定用户的权限mysql> GRANT SELECT, INSERT, UPDATE ON `db1`.* TO ‘user2‘@‘192.168.1.15‘;                                                        Query OK, 0 rows affected (0.01 sec)#在不知道密码的情况下,可以直接用show grants命令进行复制,修改ip地址 增加。

MySQL user management, common SQL statements, MySQL database backup recovery

Related Article

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.