Today, we have a course design project to use the MySQL database to execute the command line mysql-u root-P as usual. I want to open the database to create a table, but I am always prompted that I cannot open it.
I used MySQL before and installed a wampserver because I learned PHP (which contains MySQL and phpMyAdmin) at first, I thought the system had mixed up MySQL that I previously installed with the MySQL of the wampserver. So I wanted to use the command line to locate the bin directory under the specific MySQL root directory to open MySQL.
MySQL under wampserver located it in the command line. The Bin still couldn't be opened at the beginning, but I remember the password was correct. So I googled the website and said that the MySQL Default of wampserver if the root login password is empty, try it: mysql-u root-P and press enter directly when enterpassword: is prompted to log on successfully. This will know that the password was a MySQL password that was previously used, so we also located the prompt enterpassword in the bin directory of the previous MYSQL: I entered several articles according to the password I remember, but I still told me that I couldn't get in. So I got depressed and started Google again.
Google found a way to change the password without knowing the MySQL password.
First, create a text file and place the following commands in a single line:
Set password for 'root' @ 'localhost' = PASSWORD ('mynewpassword ');
Save the file with any name, in this example, the file is C:/mysql-init.txt.
Step 2: Enter the doscommand prompt: Start Menu-> Run-> cmd
Suppose you have installed MySql in C:/MySQL. If you install MySql in another location, adjust the following commands.
Run the following command at the doscommand prompt:
C:/MySQL/bin/> mysqld-NT -- init-file = C:/mysql-init.txt
When the server is started, run the "-- init-file" option (function: Read SQL commands from the specified file at startup) to change the root user password. C:/mysql-init.txt should be deleted when the server is successfully started.
If an error occurs in the mysqlserver, disable mysqld-nt.exe. Then restart it and OK.
Or stop the MySQL server and restart it in normal mode. If you run the server as a service, you should start it from the Windows service window. If the server is started manually, the command can be used as usual.
The new password should be used for connection
Certificate -----------------------------------------------------------------------------------------------------------------------------------------------------
Next: If you want to run phpMyAdmin, the following error occurs: Error 1045: Access denied for user: 'root @ localhost' (using password: Yes)
Check it out: $ cfg ['servers'] [$ I] ['Password'] = '2016 '; but the MySQL just logged on with a blank password, so I changed this to a blank password and logged on again.
Log in with a blank password on the command line and change the password.
Mysql> use MySQL
> Update user SET Password = PASSWORD ("new_password") where user = "root ";
> Flush privileges;
> Exit
Modify $ cfg ['servers'] [$ I] ['Password'] = 'new _ password' of phpMyAdmin ';
After I re-run phpMyAdmin, I still reported the following error: #1045, So I refreshed the page and successfully logged on.
Below is the collection of network resources
Change the password of MySQL again:
In Windows:
Open the command line window and stop MySQL service: net stop MySQL
Start MySQL, usually to the installation path of MySQL, find the mysqld-nt.exe
Run: mysqld-NT -- skip-grant-tables. The current window will stop.
In addition, open a command line window and run mysql. If the command is not displayed, first enter the bin directory of the MySQL installation location and then run mysql> use MySQL.
> Update user SET Password = PASSWORD ("new_password") where user = "root ";
> Flush privileges;
> Exit
Use CTRL + ALT + DEL to find the mysqld-nt process and kill it. After restarting the mysql-NT service, you can log on with the new password.
In Linux:
If MySQL is running, killall-term mysqld is first killed.
Start MYSQL: Bin/safe_mysqld -- skip-grant-tables &
You can access MySQL without a password.
Then
> Use MySQL
> Update user SET Password = PASSWORD ("new_pass") where user = "root ";
> Flush privileges;
Kill MySQL again and start MySql in a normal way.
Source: http://www.iteye.com/topic/199647
Error 1045: Access denied for user: 'root @ localhost' (using password: Yes)
Error 1045: Access denied for user: 'root @ localhost' (using password: Yes)
This error also occasionally occurred two days ago, and I did not care about it because I changed the root password of MySQL again, but it was unavailable yesterday, after I changed the root password, even though it could be used at the time, it would be useless once I re-entered it. But is there a clear error in my password? Today, we finally found the cause, which is a permission issue. You can refer to the following two articles:
Http://topic.csdn.net/t/20060117/15/4521496.html #
Http://doc.99net.net/doc/database/1076488199/1076549732.html
Since you have never encountered such a situation before, record the solution here for future reference. The specific method is to add a statement to the permission when you change the root password:
Grant all on MySQL. * To 'root' @ 'localhost' identified by 'Password ';
The last password is the password of the root user you want to modify.
At the beginning, I came to the next release with MySQL. After completing the database a few days ago, the installation manual changed the password of the root user, and then logged in with the root user. However, the error code 1045 is reported when you log on again today.
Code 1045
Access denied for user 'root' @ 'localhost' (using password: Yes)
My solution is to reset the root user password. The procedure is as follows on Windows:
1. log on to the system as a system administrator;
2. If the MySQL server is running, stop it.
If the server runs as a Windows Service, go to Service Manager: Start Menu-> Control Panel-> Administrative Tools-> services
If the server is not running as a service, you may need to use the task manager to force it to stop.
3. Create a text file and place the following commands in a single line:
Set password for 'root' @ 'localhost' = PASSWORD ('mynewpassword ');
Save the file with any name. In this example, the file is C:/mysql-init.txt.
4. Enter the doscommand prompt: Start Menu-> Run-> cmd
Suppose you have installed MySql in C:/MySQL. If you install MySql in another location, adjust the following commands.
Run the following command at the doscommand prompt:
C:/MySQL/bin/> mysqld-NT -- init-file = C:/mysql-init.txt
When the server is started, run the "-- init-file" option (function: Read SQL commands from the specified file at startup) to change the root user password. C:/mysql-init.txt should be deleted when the server is successfully started.
5. If an error occurs in the mysqlserver, disable mysqld-nt.exe. Then restart it and OK.
6. Stop the MySQL server and restart it in normal mode. If you run the server as a service, you should start it from the Windows service window. If the server is started manually, the command can be used as usual.
The new password should be used for connection.
Source: http://feidaodalian.iteye.com/blog/431926