On the homepage, how does one modify the MySQL password in CentOS for website O & M?

Source: Internet
Author: User
For server O & M, changing the MySQL password is a frequent requirement. Regular modification of the MySQL password is a guarantee of website security. Here are some commands for modifying the MySQL password for later viewing. Change the root password. The MySQL Administrator Account in CentOS is a root user by default and the password is blank. If you have never set a MySQL password,

For server O & M, changing the MySQL password is a frequent requirement. Regular modification of the MySQL password is a guarantee of website security. Here are some commands for modifying the MySQL password for later viewing. Change the root password. The MySQL Administrator Account in CentOS is a root user by default and the password is blank. If you have never set a MySQL password,

For server O & M, changing the MySQL password is a frequent requirement. Regular modification of the MySQL password is a guarantee of website security. Here are some commands for modifying the MySQL password for later viewing.

Change root Password

The MySQL Administrator Account in CentOS is a root user by default and the password is blank. If you have never set a password for MySQL, you do not need to enter a password when using the root user to connect to the MySQL server.

To set the root password for the first time, run the following command:

1 mysqladmin -u root password NEWPASSWORD

If you have already set a password, run the following command:

1 mysqladmin -u root -p'oldpassword' password newpass

For example, if the old password is "12345" and the new password is "nowamagic", run the following command:

1 mysqladmin -u root -p'12345' password 'nowamagic'

Change passwords of other MySQL users

You can use the following command to change the password of a common user, for example, the user is nmuser:

1 mysqladmin -u nmuser -p oldpassword password newpass

Another way to change the password is to store the user name and password in the user table of the MySQL database. You can use the following method to directly update the user's nmuser password:

1. log on to the mysql server:

1 mysql -u root -p

2. Select MySQL database

1 mysql> use mysql;

3. Change the nmuser Password

1 mysql> update user set password=PASSWORD("NEWPASSWORD") where User='nmuser';

4. Reset Permissions

1 mysql> flush privileges;

2 mysql> quit

This method can also be executed using scripts (PHP, Perl) without SSH to the server.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.