How to modify the MySQL password under CentOS

Source: Internet
Author: User

Do server operations, modify MySQL password is often required, regular modification of MySQL password is a guarantee of website security. Here is a record of some of the commands for modifying the MySQL password for easy viewing later. Change root password The MySQL administrator account under CentOS is the root user by default and the password is empty. If you have never set a MySQL password, you do not need to enter a password to connect to the MySQL server using the root user. The first time you set the root password you can use the following command: 1mysqladmin-u root password NewPassword If you have already set a password, you need the following command: 1mysqladmin-u root-p ' OldPassword ' Password Newpass For example, the old password is "12345", the new password is "Nowamagic", execute the following command: 1mysqladmin-u root-p ' 12345 ' password ' nowamagic ' Modify other MySQL user's password modify a password for a normal user you can use the following command, such as the user is nmuser:1mysqladmin-u nmuser-p oldpassword password Newpass Another way to change the password is to The MySQL server stores the username and password in the user table of the MySQL database. You can use the following methods to directly update the user nmuser password: 1. Log in to MySQL server: View sourceprint?1mysql-u root-p2. Select MySQL database 1mysql> use Mysql;3. Modify the nmuser password 1mysql> update user set Password=password ("NewPassword") where user= ' Nmuser '; 4. Reset permissions 1mysql> Flush Privileges;2mysql> Quit This method can also be executed with a script (Php,perl) without SSH to the server.

  

How to modify the MySQL password under CentOS

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.