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

How to reset Root password in MariaDB

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

Share

Shulou(Shulou.com)05/31 Report--

This article is about how to reset the Root password in MariaDB, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

First, stop the database.

If you are using MySQL, please enter the following command and press enter.

$sudo systemctl stop mysql

For MariaDB:

$sudo systemctl stop mariadb

Next, restart the database without permission checking using the following command:

$sudo mysqld_safe-skip-grant-tables &

Here, the-- skip-grant-tables option allows you to connect without a password and all permissions. If you start the server with this option, it also enables the-- skip-networking option, which prevents other clients from connecting to the database server. Also, the & symbol is used to run commands in the background, so you can enter other commands in the following steps. Please note that the above command is dangerous and your database will become insecure. You should only run this command for a short time to reset the password.

Next, log in to the MySQL/MariaDB server as root:

$mysql

At the mysql > or MariaDB [(none)] > prompt, run the following command to reset the root user password:

UPDATE mysql.user SET Password=PASSWORD ('NEW-PASSWORD') WHERE User='root'

Replace NEW-PASSWORD in the above command with your own password.

Then, enter the following command to exit the mysql console.

FLUSH PRIVILEGES;exit

* to close the database that was previously run with the-- skip-grant-tables option. To do this, run:

$sudo mysqladmin-u root-p shutdown

You will be asked to enter the MySQL/MariaDB user password you set in the previous step.

Now, start the MySQL/MariaDB service normally using the following command:

$sudo systemctl start mysql

For MariaDB:

$sudo systemctl start mariadb

Use the following command to verify that the password has indeed changed:

The above $mysql-u root-p is how to reset the Root password in MariaDB. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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