Detailed explanation of using mysqladmin to modify user password

1. Experimental environment:

1.1 The server operating system is centos7

1.2 The database is installed by yum

Installation command:

yum -y install mariadb mariadb-server

1.3 Start mysql service

systemctl start mariadb

2. Use the mysqladmin command to modify the user name and password

2.1 Command format (take root user as an example):

2.1.1 When the original password is empty:

Command format:

mysqladmin -uroot -p password 新密码

Examples:

[root@host-136 ~]# mysqladmin -uroot -p password 123
Enter password: 直接回车

The root password is changed to 123.

2.1.2 When the original password exists:

Command format:

mysqladmin -uroot -p旧密码 password 新密码

Examples:

[root@host-136 ~]# mysqladmin -uroot -p123 password 456

The root password is changed from 123 to 456.

note!!!

Do not use single or double quotes when setting the password

Such as:mysqladmin -u root -p password '123'

Otherwise, the password will be changed to the 5-character '123' instead of the 3-character.

Guess you like

Origin blog.csdn.net/m0_46674735/article/details/112692395