Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction to the method of quickly changing the password of mysql Database under linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The following mainly brings you the method of quickly changing the password of mysql database under linux. I hope these contents can bring you practical use, which is also the main purpose of this article that I edit the method of quickly changing the password of mysql database under linux. All right, don't talk too much nonsense, let's just read the following.

Modify the use of Mysql under Linux (password of root and modify login permissions of root

All modified users have root as the column.

First, know the root password of the original myql database

①: enter mysqladmin-u root-p password "new password" on the terminal command line and enter Enter password: / * enter the old password * /

②: log in to the mysql system to modify, mysql-uroot-p enter Enter password: / * enter the original password * /

Mysql > use mysql;mysql > update user set password=password ("new password") where user='root'; / * password pay attention to case * / mysql > flush privileges;mysql > exit;service mysqld/mysql statusservice mysqld/mysql restart/start

Then you can log in using the new password you just entered.

Second, do not know the password of the original myql root

First of all, you must have root permission for the operating system. If you don't even have root permission for the system, consider the root system before taking the following steps. Similar to logging into the system in safe mode.

You need to stop the mysql service first. There are two cases here. One can use service mysqld stop.

The other is / etc/init.d/mysqld stop

When prompted that mysql has stopped, proceed to the next operation Shutting down MySQL. SUCCESS!

Enter at the terminal command line

Mysqld_safe-- skip-grant-tables & / * Log in to mysql system * /

Enter mysql to log in to the mysql system

Mysql > use mysql;mysql > UPDATE user SET password=password ("new password") WHERE user='root'; / * password pay attention to case * / mysql > flush privileges;mysql > exit

Restart the mysql service

So the new root password is set successfully.

3. Modify root login permissions

This is very likely to happen when you change your root password.

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

This is due to insufficient login permissions in root. The specific modification methods are as follows

You need to stop the mysql service first. There are two cases here. One can use service mysqld stop.

The other is / etc/init.d/mysqld stop

When prompted that mysql has stopped, proceed to the next operation Shutting down MySQL. SUCCESS!

Enter at the terminal command line

Mysqld_safe-- skip-grant-tables & / * Log in to mysql system * /

Enter mysql to log in to the mysql system

Mysql > use mysql;mysql > update user set host ='% 'where user =' root';mysql > select host, user from user;mysql > flush privileges;mysql > exit;service mysqld/mysql statusservice mysqld/mysql restart/start

Then restart the mysql service.

First sentence: log in as the authorized user root

Second sentence: select mysql library

The third sentence: check the host value of the user table in the mysql library (that is, the name of the host / IP for connection access)

Fourth sentence: modify the host value (add the host / IP address with wildcard%), of course, you can also directly increase the IP address.

If this step goes wrong "ERROR 1062 (23000): Duplicate entry'%-root' for key 'PRIMARY'" by indicating that the record exists, skip this step

Fifth sentence: refresh the system permission related table of MySQL

The sixth sentence: when you re-look at the user table, there are changes.

Restart the mysql service to complete.

MariaDB sets initialization password and modifies password

Method 1:

[root@localhost ~] # mysqlMariaDB [(none)] > UPDATE mysql.user SET password = PASSWORD ('newpassword') WHERE USER =' root';MariaDB [(none)] > FLUSH PRIVILEGES

Method 2:

[root@localhost ~] # mysqlMariaDB [(none)] > SET password=PASSWORD ('newpassward')

Method 3:

[root@localhost] # mysqladmin-u root password' newpassword'

If root has already set a password, use the following methods

[root@localhost] # mysqladmin-u root-p 'oldpassword' password' newpassword'

Modify the use of Mysql under Linux (password of root and modify login permissions of root

All modified users have root as the column.

First, know the root password of the original myql database

①: enter mysqladmin-u root-p password "new password" on the terminal command line and enter Enter password: / * enter the old password * /

②: log in to the mysql system to modify, mysql-uroot-p enter Enter password: / * enter the original password * /

Mysql > use mysql;mysql > update user set password=password ("new password") where user='root'; / * password pay attention to case * / mysql > flush privileges;mysql > exit;service mysqld/mysql statusservice mysqld/mysql restart/start

Then you can log in using the new password you just entered.

Second, do not know the password of the original myql root

First of all, you must have root permission for the operating system. If you don't even have root permission for the system, consider the root system before taking the following steps. Similar to logging into the system in safe mode.

You need to stop the mysql service first. There are two cases here. One can use service mysqld stop.

The other is / etc/init.d/mysqld stop

When prompted that mysql has stopped, proceed to the next operation Shutting down MySQL. SUCCESS!

Enter at the terminal command line

Mysqld_safe-- skip-grant-tables & / * Log in to mysql system * /

Enter mysql to log in to the mysql system

Mysql > use mysql;mysql > UPDATE user SET password=password ("new password") WHERE user='root'; / * password pay attention to case * / mysql > flush privileges;mysql > exit

Restart the mysql service

So the new root password is set successfully.

3. Modify root login permissions

This is very likely to happen when you change your root password.

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

This is due to insufficient login permissions in root. The specific modification methods are as follows

You need to stop the mysql service first. There are two cases here. One can use service mysqld stop.

The other is / etc/init.d/mysqld stop

When prompted that mysql has stopped, proceed to the next operation Shutting down MySQL. SUCCESS!

Enter at the terminal command line

Mysqld_safe-- skip-grant-tables & / * Log in to mysql system * /

Enter mysql to log in to the mysql system

Mysql > use mysql;mysql > update user set host ='% 'where user =' root';mysql > select host, user from user;mysql > flush privileges;mysql > exit;service mysqld/mysql statusservice mysqld/mysql restart/start

Then restart the mysql service.

First sentence: log in as the authorized user root

Second sentence: select mysql library

The third sentence: check the host value of the user table in the mysql library (that is, the name of the host / IP for connection access)

Fourth sentence: modify the host value (add the host / IP address with wildcard%), of course, you can also directly increase the IP address.

If this step goes wrong "ERROR 1062 (23000): Duplicate entry'%-root' for key 'PRIMARY'" by indicating that the record exists, skip this step

Fifth sentence: refresh the system permission related table of MySQL

The sixth sentence: when you re-look at the user table, there are changes.

Restart the mysql service to complete.

MariaDB sets initialization password and modifies password

Method 1:

[root@localhost ~] # mysqlMariaDB [(none)] > UPDATE mysql.user SET password = PASSWORD ('newpassword') WHERE USER =' root';MariaDB [(none)] > FLUSH PRIVILEGES

Method 2:

[root@localhost ~] # mysqlMariaDB [(none)] > SET password=PASSWORD ('newpassward')

Method 3:

[root@localhost] # mysqladmin-u root password' newpassword'

If root has already set a password, use the following methods

[root@localhost] # mysqladmin-u root-p 'oldpassword' password' newpassword'

For the above method of quickly changing the password of mysql database under linux, do you think it is very helpful? If you need to know more, please continue to follow our industry information. I'm sure you'll like it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report