1.ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes)
1) Turn off the MySQL service
/etc/init.d/mysqld stop
2) Enable Safe Mode & background operation
Mysqld_safe--user=mysql--skip-grant-tables--skip-networking &
3) Login
Mysql-u Root mysql
////////////////
Branch One:
4) Query User table
Mysql> select * from user;
5) Insert New user
mysql> INSERT INTO User (Password,user) VALUES (Password (' root '), ' root ');
Attention:
Insert into User (Password,user) VALUES (' 123 ', ' root '); No, because the secret must be encrypted with the Password () function.
mysql>quit;
Tip: The second time you execute an INSERT statement, the same root, password will prompt the following error message
mysql> INSERT INTO User (Password,user) VALUES (Password (' root '), ' root '), error 1062 (23000): Duplicate entry ' roo T ' for key ' PRIMARY '
Branch Two:
mysql> UPDATE user SET Password=password (' NewPassword ') where user= ' root ';
mysql> FLUSH privileges; Remember to say this, otherwise if you close the previous terminal, the original error will appear
Mysql> quit
////////////////
6) Restart MySQL service
/etc/init.d/mysqld start
7) Login
Mysql-u root-p
Enter Password: < Enter the new password newpassword>//is still a failure. Tip Error 1045 (28000); Reset the root password by UPDATE to 1234 instead of root, and then successfully landed
Mysql>
2.mysql_real_connect connection to database error:
about how to use Mysql_real_connect () to connect to a remote database
Http://www.cnitblog.com/guopingleee/archive/2009/02/14/54548.html
(GDB) P m_pszipaddress
$ = "localhost", ' \000 ' <repeats times>
(GDB) P M_pszusername
$ = "root", ' \000 ' <repeats times>
(GDB) P M_pszuserpassword
$ $ = "1234", ' \000 ' <repeats times>
(GDB) P M_pszdatabasename
$4 = "Mytestdb", ' \000 ' <repeats times>
If the second parameter
const char *host,//Connection host
Set to localhost, calling Mysql_real_connect can run successfully.
When you change to 192.168.1.100, the following error is reported:
$ = "Access denied for user ' root ' @ ' to database ' Mytestdb ', 42000", ' \000 ' <repeats 961 times>
After executing the following code, the error prompt changes to:
Mysql-u root-p
Enter password
Grant all privileges the on database name . * to ' root ' @ '% '; Database name such as: Mytestdb
$ = "Access denied for user ' root ' @ ' 192.168.88.131 ' (using Password:yes), 28000", ' \000 ' <repeats 948 times>
Do not know how to deploy MySQL database.
3.
Q: The following error occurred while logging on to MySQL on another machine:
ERROR 2003 (HY000): Can ' t connect to MySQL server on ' x.x.x.x ' (111)
A: Because MySQL takes security into account, the default configuration only lets you log on locally
Open the/etc/mysql/my.cnf file, locate bind-address = 127.0.0.1 modified to bind-address = 0.0.0.0///etc/mysql/my.cnf cannot find this file.
Restart mysql:sudo/etc/init.d/mysql Restart
Q: There is a situation similar to the following error:
ERROR 1045 (28000): Access denied for user ' test ' @ ' x.x.x.x ' (using Password:no)
A: The reason is that the logon user name is not set to the remote host logon permission.
Log in locally with root: Mysql-u root-p
Modify the Host field in the user table in the MySQL database to apply the user name, and change localhost to%
Use MySQL;
Update user Set Host = '% ' where user = ' username ';
MYSQL problems and how to solve them