catalogs
-
Initializing, modifying and resetting mysql passwords
- For the record:
- Initialize password (initialize password before first use)
- View password (logged in status)
- Change password (original password known)
-
Forgot your password (password recovery)
- Novo mysql installed on Windows
- Novo mysql installed on Linux
- Ending systemctl why you can manage mysql attachments
Initializing, modifying and resetting mysql passwords
For the record:
writingsguixiang
Original, all hands-on, do not know how to leave a message to ask.
Initialize password (initialize password before first use)
1. Enter the mysql command line
mysql -uroot
2. Execute
ALTER USER'root'@'localhost'IDENTIFIED BY 'your_password';
3. Submit
flush privileges.
4. Exit
quit;
View password (logged in status)
mysql> select * from ;
# Find this:
| 127.0.0.1 | root | *FD408300A2CBA95D1FCBB97C4E21D38D4B7E446D | % | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
| % | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
# Go to the website: decrypt the md5 encrypted text
# columns such as *FD408300A2CBA95D1FCBB97C4E21D38D4B7E446D are ciphertexts
Change password (original password known)
1. Enter the mysql command line
mysql -uroot -p
2. Execute
set password for root@localhost = password('your_new_password');
#Make sure you have a root@localhost user for this method.
#User view
SELECT user, host FROM ;
#If you are just updating the current user (this method will work)
SET PASSWORD = PASSWORD('your_new_password') ;
3. Exit
quit;
[!CAUTION]
Before Noe:
2.fulfillmentuse mysql; 3.fulfillmentupdate user set host = '%' where user = 'root'; 4.fulfillmentFLUSH PRIVILEGES;
sign in as
[root@bogon ~]# mysql -uroot -h127.0.0.1
Forgot your password (password recovery)
Novo mysql installed on Windows
1. open cmd and stop mysql
net stop mysql
2. Enter mysqld (CMD command line window should go to mysql\bin directory)
mysqld --skip-grant-tables
3. Open a new CMD and enter the mysql command line.
mysql -uroot
4. Execute
use mysql;
5. Change the password
set password for root@localhost = password('your_password');
or
SET PASSWORD = PASSWORD('your_new_password');
6. Refresh the permission table
flush privileges.
7. Exit
quit;
[!CAUTION]
Stop mysql second way above
Find the MySQL service in Task Manager and stop it.
Novo mysql installed on Linux
1. Stop mysql
service mysqld stop
# It could also be something like this (since I wrote a special startup file earlier, I'll put this later)
[root@bogon ~]# systemctl stop mysqld
2. Modify
vim /etc/
Under mysqld, add
[mysqld]
skip-grant-tables
3. Reboot
service mysqld start
# Or it could be something like this (since I wrote a special startup file earlier, I'll put this later)
[root@bogon ~]# systemctl start mysqld
4. Enter mysql
mysql -uroot
5. Execute
use mysql;
6. Change the password
use mysql;
UPDATE user SET authentication_string=PASSWORD("your_new_password") WHERE User="root";
# use mysql before 5.7 (extremely important)
update user set password=password("your_new_password") where User="root";
#View the version:
mysql --version
7. Refresh the permissions table
flush privileges.
8. Exit
quit;
9. Stop mysql
service mysqld stop
# It could also be something like this (since I wrote a special startup file earlier, I'll put this later)
[root@bogon ~]# systemctl stop mysqld
10. Delete (note that you are deleting the skip-grant-tables section)
vim /etc/
[mysqld]
skip-grant-tables
11. Restart mysql
service mysqld start
# Or it could be something like this (since I wrote a special startup file earlier, I'll put this later)
[root@bogon ~]# systemctl restart mysqld
[!CAUTION]
Step 6, don't try both, because the new columns will scramble the password and cause you to fail to log in!
Ending systemctl why you can manage mysql attachments
vim /usr/lib/systemd/system/
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=/doc/refman/en/
After=
After=
[Install]
WantedBy=
[Service]
User=mysql
Group=mysql
ExecStart=/application/mysql/bin/mysqld --defaults-file=/etc/
LimitNOFILE = 5000