How to set the password for Mysql database
The following is about how to set the password for the Mysql database. The secret of the text is that it is close to the topic. So, no gossip, let's go straight to the following, I believe you will benefit from reading this article on how to set the password for the Mysql database.
Mysqladmin-u username-p password 'new password' # Linux command line
Set password=password ('new password'); # change the password for the current login user under the database command line
Set password for user name @ host address = password ('new password'); # change the password for a user under the database command line
Update mysql.user set password=password ('new password') where user=' user name 'and host=' host address'; # change the password for a user under the database command line
Under the database command line, you need to use the flush privieleges; command to refresh the cache after changing the password
Mysql forgot the login user password. Reset method:
Method 1:
1. Systemctl stop mariadb.service # stop database service
two。 Edit the / etc/my.cnf file and add the following:
Skip-grant-tables
3. After systemctl restart mariadb.service # restarts the database service, use the mysql command to log in to the database without a password (safe mode at this time)
4. Use the update command to change the password in safe mode in the database.
5. Stop the database service
6. Comment or delete the line skip-grant-tables in the / etc/my.cnf file
7. Restart the database service
Method 2:
1. Systemctl stop mariadb.service # stop database service
two。 Execute the mysqld_safe-- skip-grant-tables command to enter database security mode
3. Use the mysql command on other terminals to log in to the database without a password.
4. Use the update command to change the password.
Is there anything you don't understand about how to set the password of the Mysql database above? Or if you want to know more about it, you can continue to follow our industry information section.