This article mainly introduces MySqlSolutions for forgotten login passwords and forgotten mysql The quick solution to the password is very good and has reference value. Friends who need it can refer to it
Method 1:
access control. Start the MySQL server with this command on the command line:
safe_mysqld --skip-grant-tables&
MySQL database as an administrator.
It should be noted that after changing the password, you must stop and restart the MySQL server for it to take effectMethod 2:
You can follow the steps below to reset the MySQL root password: 1. First, confirm that the server is in a safe state, that is, No one can connect to the MySQL database arbitrarily Because during the period of resetting the MySQL root password, the MySQL database is completely unprotected by a password, and other users can also log in and modify the MySQL database at will. Information. You can close MySQL's external port and stop Apache and all user processes to achieve a quasi-safe state. The safest state is to operate on the server's Console and unplug the network cable. #2. Modify MySQL login settings:# vi /etc/my.cnf
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock skip-name-resolve skip-grant-tables
# /etc/init.d/mysqld restart Stopping MySQL: [ OK ] Starting MySQL: [ OK ]
#
# /usr/bin/mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 to server version: 3.23.56 Type ‘help;' or ‘\h' for help. Type ‘\c' to clear the buffer. mysql> USE mysql ; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> UPDATE user SET Password = password ( ‘new-password' ) WHERE User = ‘root' ; Query OK, 0 rows affected (0.00 sec) Rows matched: 2 Changed: 0 Warnings: 0 mysql> flush privileges ; Query OK, 0 rows affected (0.01 sec) mysql> quit Bye
# vi /etc/my.cnf
6. Restart mysqld
# /etc/init.d/mysqld restart Stopping MySQL: [ OK ] Starting MySQL: [ OK ] windows
1. Log in to the system as the system administrator. .
2. Open cmd--net start to see if mysql is started. If it is started, stop net stop mysql.
3. My mysql is installed in d:\usr\local. \mysql4\bin. 4. Skip permission check and start mysql.
d:\usr\local\mysql4\bin\mysqld-nt –skip-grant-tables
5. Reopen cmd. Go to d:\usr\local\mysql4\bin:
d:\usr\local\mysql4\bin\mysqladmin -uroot flush-privileges password “newpassword”
d:\usr\local\mysql4\bin\mysqladmin -u root -p shutdown This prompts you to re-enter your password.
6. Net start mysql in cmd
7. Done.
# SET PASSWORD FOR 'some_user'@'some_host' = OLD_PASSWORD(‘newpwd'); # FLUSH PRIVILEGES;
myisamchk -r -q d:\mysql\data\latin1\*
r represents repair
q Represents fast
d:\mysql\data\latin1\*In the database*Represents all the files in it
Method three:
If you forget your MYSQL root password, you can restore it through the following process. 1. Send the kill command to mysqld server to shut down the mysqld server (not kill -9). The file storing the process ID is usually in the directory where the MYSQL database is located. kill `cat /mysql-data-directory/hostname.pid`
3. Use the `mysql -h hostname mysql' command to log in to the mysqld server, and use the grant command to change the password. You can also do this: `mysqladmin -h hostname -u user password 'new password''.
(In fact, you can also use use mysql; update user set password =password('yourpass') where user='root' to do it.)
4. Load the permission table: ` mysqladmin -h hostname flush-privileges' , or use the SQL command `FLUSH PRIVILEGES'. (Of course, you can also restart mysqld here.)
Method 4: (Be sure to back up first)
1, restart Install the same version of MySQL on another computer2, delete all the contents of \data\mysql in the MySQL installation directory on the computer that has forgotten the password (stop the MySQL service first) 3,Copy新装的电脑上MySQL安装目录中\data\mysql的全部内容 to 刚刚删除的目录中 4,启动MySQL服务 PS:下面看下Mysql忘记密码解决方案 解决方法如下: 1、终端中结束当前正在运行的MySQL进程。 2、用mysql安全模式运行并跳过权限验证。 3、ctrl+T重开一个终端以root身份登录mysql。 4、修改root用户口令。 注意:括号里的'root'就是新密码。 5、结束mysql安全模式,用正常模式运行mysql。 6、试试你新修改的口令登陆MySQL 输入密码 root 刷新账户后,退出。# sudo /etc/init.d/mysql stop
# sudo /usr/bin/mysqld_safe --skip-grant-tables
# mysql -u root
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set Password = PASSWORD('root') where User ='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> exit
# sudo /etc/init.d/mysql restart
#myslq -u root -p
mysql> show grants for 'root'@'127.0.0.1';
mysql> flush privileges;
mysql> quit;
The above is the detailed content of Detailed explanation of forgotten MySql login password and solutions to forgotten passwords (picture). For more information, please follow other related articles on the PHP Chinese website!