Home > Database > Mysql Tutorial > body text

How to change MySQL password in centos

PHPz
Release: 2023-04-21 11:37:10
Original
3602 people have browsed it

CentOS MySQL password modification

MySQL is a popular relational database management system. On the CentOS operating system, MySQL is a common database server used to store and manage large amounts of data. In order to ensure the security of the MySQL database, we need to change the MySQL password regularly.

This article will introduce you to the steps to change the MySQL password in CentOS, including using command line and graphical interface management tools.

Step 1: Use the command line to change the MySQL password

1. Connect to the CentOS server via SSH and enter the following command to log in to MySQL:

sudo mysql -u root -p

Note: If you have set a password before, you need to enter the MySQL administrator's password after -p.

2. Enter the following command to change the MySQL administrator's password:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword';

Note: Change " NewPassword" with the new password.

3. Exit MySQL:

exit;

Step 2: Use phpMyAdmin to change the MySQL password

phpMyAdmin is a popular MySQL database management tool. Provides a graphical user interface to manage MySQL databases. If you use phpMyAdmin as your MySQL management tool, you can use the following steps to change your MySQL password.

1. Connect to the CentOS server via SSH and enter the phpMyAdmin directory:

cd /usr/share/phpMyAdmin/

2. Copy the configuration file:

sudo cp config.sample.inc.php config.inc.php

3. Edit the configuration file and add the MySQL administrator account information:

sudo nano config.inc.php

$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'oldpassword';

Note: Replace "oldpassword" with the administrator's current password.

4. Log in to phpMyAdmin and select "Change Password" under the "Server" tab.

5. Enter the current administrator password and the new password, then click "Go".

6. Reload the page to use the new password.

Summary

This article introduces two ways to change the MySQL password using the command line and phpMyAdmin in CentOS. These steps can help administrators secure their MySQL servers. When you decide to change your MySQL password, make sure your new password is strong enough and do not share it with other accounts.

The above is the detailed content of How to change MySQL password in centos. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!