Modifying the MySQL root password method in Linux

Source: Internet
Author: User

Using Mysqladmin
#./mysqladmin-u root password ' newpassword ' #./mysqladmin-u root-h host_name password ' newpassword '
Usually mysqladmin ' s path is/usr/bin, HOST_NAME is your real host name, e.g. Localhost.localdomain. The quotation marks after the password are not required, but if the password contains spaces or some special symbols, quotation marks are required.Using the MySQL SET password command
#./mysql-u rootmysql> set PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' newpassword ');mysql> set PASSWORD for ' root ' @ ' host_name ' = PASSWORD (' NewPassword ');
Updating the user table with the UPDATE statement resets the root password
#./mysql-u rootmysql> UPDATE mysql.user SET Password = Password (' newpassword ') WHERE user = ' root ';mysql> FLUSH PR Ivileges;
Manually Modify 1. Stop MySQL Service Execution:/etc/init.d/mysql stop, your machine is not necessarily/etc/init.d/mysql or it may be/etc/init.d/mysqld 2. Skip verification to start MySQL/usr/local/mysql/bin/mysqld_safe--skip-grant-tables >/dev/null 2>&1 & Note: if Mysqld_ Safe position if not the same as above needs to be modified to you, if not clear can be found with the Find command.3. Reset the password for a moment, and then execute:/usr/local/mysql/bin/mysql-u root mysql appears after MySQL prompt input: Update user Set password = password (' Password to set ') whe Re User = ' root ';    Enter after execution: flush privileges; Refreshes the MySQL system permissions related tables.  Re-execution: exit; Exit.4. Restart MySQL to kill MySQL process: killall mysqld restart Mysql:/etc/init.d/mysql start

Modifying the MySQL root password method in Linux

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.