On Mysql reset password

Beginners start with MySQL, they might easily forget the password, said the following about how to reset and change passwords

The first method: in command window operation
is stopped mysql server (which is the focus: immediately stop)
open CMD input disk installed MySQL command line window
then enter mysql installation bin directory path, such as E> cd amp \ mysql5 .5 \ bin, the enter input> mysqld --skip-grant-tables (except a front --skip empty compartment, the other must be connected together in a few)
then enter a command line window will not
then open another CMD window
with the above operation, the input Bin path
followed by direct input mysql, focus only need to enter mysql.
to enter the password authentication MySQL skip the welcome screen
and then change the password
syntax
update mysql.user password = password (123456) where user = 'root'
modify password successfully
and refresh (refresh process without restarting the server, the mysql permission tables extracted from the library to the memory, to avoid the next time you log unsuccessful refresh can directly view, can effectively avoid the login failures)
flush privileges
refresh successfully
then quit quit
close all CMD window
and then open a new window, enter your password

 

The second method: in a configuration file to modify the MySQL root directory
# to find the root mysql
# My.ini find the configuration file in the root directory
# locator to find a [mysqld]
# in [mysqld] Enter key to this line,
# Norway a cell and then enter the skip-grant-tables (stick together at the bar, otherwise easily lead to restart the server failure), (belonging to skip the password verification process, reducing the security of the database)
# restart the database service (priorities, the need to re start the server can not be closed)
# open CMD command line window
# direct input mysql -uroot -p (do not lose the installation path)
# direct the enter key to skip entering a password step
# successful login
# start password (update mysql.user set password password = (123456) the WHERE the User = 'root')
# password refresh (flush privileges) / prɪvəlɪdʒ /)
# exit find my.ini, the skip-grant-tables to delete
# restart the database server


# Key
1.mysql installation path if installed in C drive, you do not need the command line window enter the installation path mysql. Direct input of the skip command statement codes.

Guess you like

Origin www.cnblogs.com/guiguizhu/p/12044003.html