This article mainly introduces Mysqldetailed tutorial on setting the password for the installation-free version. Friends who need it can refer to
Method 1: Use the SET PASSWORD command
MySQL -u root mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
Method 2: Use mysqladmin
mysqladmin -u root password "newpass"
If root has already set a password, use the following method
mysqladmin -u root password oldpass "newpass"
Method 3: Use UPDATE directly Edit the user table
mysql -u root mysql> use mysql; mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root'; mysql> FLUSH PRIVILEGES;
When you lose the root password, you can do this
mysqld_safe --skip-grant-tables& mysql -u root mysql mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root'; mysql> FLUSH PRIVILEGES;
The above is the detailed explanation of the password setting tutorial for the Mysql installation-free version introduced by the editor. I hope it will be helpful to you. This is helpful to everyone. If you have any questions, please leave me a message and I will reply to you in time!
【Related recommendations】
1. Free mysql online video tutorial
2. MySQL latest manual tutorial
3. Six days to take you through MySQL video tutorial
The above is the detailed content of Share 3 ways to set passwords for Mysql installation-free version. For more information, please follow other related articles on the PHP Chinese website!