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