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