When MYSQL is installed, the password configuration interface will pop up by default, which shows the password of the root user, but once you forget it, you can only find a way to reset it. There are several ways to reset the ROOT password.
Method 1. Use 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, eg localhost.localdomain.
The quotation marks after the password are not required, but if the password contains spaces or some special symbols, Quotes are required.
Method 2, use mysql SET PASSWORD command
# ./mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpassword ');
mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpassword');
Method 3. Update the user table with the UPDATE statement to reset the ROOT password
# ./mysql -u root
mysql> UPDATE mysql.user SET Password = PASSWORD('newpassword') WHERE User = 'root';
mysql> FLUSH PRIVILEGES;
Method 4, start MYSQL safe mode reset ROOT password
1, stop MySQL process
Execute: /etc/init.d/mysql stop, specific location may Depending on the system, it may be /etc/init.d/mysql, /etc/init.d/mysqld, etc., or terminate directly below (preferably do not use the following mandatory statement):
# killall -TERM mysqld
2, start MySQL in safe mode
# mysqld_safe –skip-grant-tables &
or,
# Mysqld_safe --skip-grant-tables >/dev/null 2>&1 &
Tip: mysqld_safe is generally /Usr /local /mysql /bin /directory.
3, login MYSQL
After completing the above two steps, you can enter MySQL without password
# mysql -u root
or,
# /usr/local/mysql/bin/mysql -u root mysql
4, change the ROOT password
The following sentences are executed in order:
use mysql;
select host, user, password from user;
update user set password=password(“newpassword”) where user=”root”
flush privileges;< Br>
5. Exit the console and restart the MYSQL service
service mysqld restart
or,
/etc/init.d/Mysql restart
Matthew Garrett, Core Developer from Red Hat, publishes a detailed article on Fedora 18. It will int
Among the many members of the MCU family, MCS-51 series MCUs occupy industrial measurement and contr
That day, my colleague showed me an operation step on my computer, using an env command, well, I adm
The disk sector defaults to 512 bytes. To verify, execute it from the command line: fdisk -l
Linux zombie process and its solution
Linux release cache memory tutorial
How to configure the wireless network card under Linux system
LINUX system disk space full clear method
How to install JDK1.5 under Linux
How to find IP address conflicts in Linux
How to learn linux programming
CentOS/RHEL Minimize installation and install setup configuration tool
How to solve Windows 8 system application download errors
Windows 7 Comic Album: Protect Game Accounts (4)
Win10 store recovery details PC and mobile phone can access and download applications normally
Experts explain WinXP system optimization acceleration three absolutely
How to log in using the administrator administrator account under Win8.1 system
Play the recycle bin to make the garbage change treasure
Win7 hard disk installation method to use the software
How to use the knockout software to illustrate the graphic presentation