Problem description
Access Mysql:error 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)
Workaround
First, modify the root user's password
Method One:
/etc/init.d/mysql stopmysqld_safe--user=mysql--skip-grant-tables--skip-networking &//Skip permissions Mysql-u root mysql**
mysql> UPDATE user SET Password=password (' NewPassword ') where user= ' root ';
mysql> FLUSH privileges;
Mysql> quit
/etc/init.d/mysql restartmysql-uroot-p
Enter Password: < Enter the newly set password newpassword>
Mysql>
Method Two
Use Mysqladmin. Input
Mysqladmin-u root-p OldPassword newpasswd
After executing this command, you need to enter the root's original password so that the root password will be changed to NEWPASSWD. Similarly, you can change your password by changing the root of the command to your username.
Of course if your mysqladmin is not connected to MySQL server, or you have no way to execute mysqladmin, then this method is invalid, and mysqladmin cannot empty the password.
The following methods are used at the MySQL prompt and must have root privileges for MySQL:
Method Three
Mysql> INSERT into Mysql.user (Host,user,password) VALUES ('% ', ' admin ', Password (' admin '));
Mysql> FLUSH Privileges
This is the addition of a user, username and password for admin. Note that you use the password function, and then you use the flush privileges to perform the acknowledgment.
Method Four
As with method Three, just use the Replace statement
Mysql> REPLACE into Mysql.user (Host,user,password) VALUES ('% ', ' system ', Password (' manager '));
Mysql> FLUSH Privileges
Method Five
Using the Set Password statement
mysql> SET PASSWORD for [email protected] "%" = PASSWORD (' manager ');
You must also use the password () function, but you do not need to use flush privileges to perform acknowledgments.
Method Six
Use Grant ... The identified by statement to authorize.
Mysql> Grant all privileges the [email protected] identified by ' Admin123 ' with GRANT option;
Mysql> FLUSH Privileges
Here the password () function is unnecessary and does not require the flush privileges to perform the acknowledgment.
PASSWORD () function is for password word encryption, in the program MySQL automatic interpretation.
Remote access to MySQL