MySQL Database user Management

Source: Internet
Author: User

MySQL User management New user

Mysql-u root-p//login MySQL

use MySQL;//Enter database MySQL
Command format create user ' username ' @ ' localhost ' identified by ' password '

Use redaction as user password

Select password (123123);

View User

use MySQL;//Enter database MySQL
Select User,authentication_string,host from user; View User

Delete User
> drop user ‘abc‘@‘localhost‘;        //删除用户abc
Renaming a user
> rename user ‘abc‘@‘localhost‘ to ‘msq‘@‘localhost‘; (//将用户abc 重命名为 msq)
Set Password
 > set password=password(‘123456‘);   (设置当前用户密码为123456) > set password for ‘abc‘@‘localhost‘=password(‘abc123‘);  (//设置其他用户abc的密码为abc123)
Workaround for forgetting the root user password when using MySQL 1. Close the database
 systemctl stop mysqld.service    //关闭mysql服务
2. Start the database using Mysqld--skip-grant-tables
mysqld --skip-grant-tables  //启动Mysql
3. After booting, you need to log in to MySQL on a terminal and use update to change the root password.
 source /etc/profile        //刷新下环境变量         mysql                           //进入数据库> update mysql.user set authentication_string=password (‘123123‘) where user=‘root‘;    (//修改mysql库 user表 root用户的密码为123123)
4: Refreshing the database
    > flush privileges;    //刷新数据库
5: Sign in to test with new password
 mysql -u root -p 123123

MySQL Database user Management

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.