Mysql 5.6 Modifying root Password Tutorial
- 2021-11-13 18:31:31
- OfStack
1. After MySQL 5.6 is installed, it cannot be enabled properly
Compressed version of MySQL, after decompression, in: my computer- > Attributes- > Advanced- > Environment variable
Select PATH and add the path to the mysql bin folder after it (for example: C:\ Program Files\ MySQL\ MySQL Server 5.6\ bin)
Modify or add configuration at my-default. ini:
[mysqld]
basedir=C:\Program Files\MySQL\MySQL Server 5.6 ( mysql Directory in which)
datadir=C:\Program Files\MySQL\MySQL Server 5.6\data ( mysql Directory in which \data )
port = 3306
To run cmd as an administrator, enter
mysqld -install
After the installation is successful, the service will start. Continue to enter in cmd:
net start mysql
The service started successfully!
After the service starts successfully, you can log in, as shown in the figure, enter
mysql -u root -p
(No password for the first login, press Enter directly), login is successful!
2. MySQL 5.6 Forgot root password
First
net stop mysql
Service, and switch to Task Manager, there are mysql related, it is best to close the process.
Run the CMD command to switch to the MySql installation bin directory and execute
mysqld �skip-grant-tables
(Note that there is no semicolon.)
Do not close this command line window, and reopen a new command line window. Note that sometimes a warning will appear at this time, so just ignore it.
Open a new cmd window again. Run the above method to the bin directory and run the command:
mysql -u root -p
Prompt for password and enter directly
Execute a command:
update mysql.user set password=PASSWORD( ' root') where User='root';
Refresh execution:
mysql> flush privileges;
Close the window and log in
3. Create 1 user and give 1 permissions (select, delete, update, create, drop permissions)
Log in with a user with all permissions
Create a user:
mysql> insert into mysql.user(Host,User,Password) values( " localhost " , " test " ,password( " 1234 " ));
Authorize the user: grant permission on database. * to user name @ login host identified by "password";
Refresh the system permission table:
mysql>flush privileges;
Example 1:
mysql>grant select,update on testDB.* to test@localhost identified by '1234';
mysql>flush privileges;
Summarize