Install MySQL 1045 and other errors under Windows Linux

Source: Internet
Author: User
Tags mysql in mysql login

There have been no problems with installing MySQL under Windows. There were some problems when installing Linux, and there were 1045 errors yesterday when Windows was installed. In terms of personal experience this problem is the root user password problem, so the way to summarize the solution is as follows:

One, MySQL login 1045 error

Mysqladmin:connect to server at ' localhost ' failed
Error: ' Access denied for user ' root ' @ ' localhost ' (using Password:yes) '

We see the above error that the user is the root host for localhost password problem, so we have to look at the MySQL database user table in user root, Host is the password of this user for localhost.

Workaround: Crack the Mysqlpassword

1. Service Mysqld Stop

Stop MySQL Service

2, Mysqld_safe--skip-grant-tables

//The configuration file in MySQL is assumed to be Linux (CentOS) in the ETC/MY.CNF configuration file Mysqld_safe next day to join Skip-grant-tables, assuming under Windows is under the installation folder My.ini Mysqld The configuration file is added under Skip-grant-tables, Skip-grant-tables is skipping the authorization table , So the configuration is saved off, Start the MySQL service again

3, Mysql-uroot-p return

That's it, there's two problems here. is also the two cases that I have encountered, one is the user table has users as root. One is not, assuming that there is a process such as the following:

(1), use MySQL;

Using the MySQL Database


(2), delete from user where host= "localhost" and user= "";

The user who is empty under host localhost is deleted. In fact, you can change this to a% to avoid connecting later when the connection is not, but it is something here should not be able.

(3), update user set Password=password ("Newpass") where user= "root";
If you look at the query you will find that the password in MySQL is encrypted, so the change password can not be the same as the usual SQL to use password ("New password") keyword to change password. The new password is a character in the password.

(4), flush tables;

Data brush to disk


(5), flush privileges;

Update permissions


(6), quit

Exit

(7), in the configuration file skip-grant-tables Stare/delete Save

(8), service mysqld restart

Start the service again mysql-uroot-p the new password carriage return. It's supposed to be.

Second, the above 3, mysql-uroot-p enter after entering the use table no data, that is, create the root user to do such as the following processing:

In the first case, the user is rooted but not connected to Windows, and nothing in user is encountered under Linux (CentOS), for example, the following:


After installing MySQL in Linux after the error, just started to think that is the first such a situation, most of the internet is also this kind of article has been changed according to this article: Linux under the first login changes password after the change should be correct, However, it is not possible to start the service root login again, the following is the problem and resolution process:

1, the query to see whether user is the root users, or this said user has no practical account.

Mysqld_safe--Skip-Grant-Tables&mysql-Uroot MySQL
Mysql>Select*From user;
Empty Set(0.XX sec)
Mysql>Select USER();
+--------+
|USER()|
+--------+
|[Email protected]|
+--------+
1 rowinchSet(0.XX sec)

The result is that there is no root user and the user table is empty. It's the first time you've ever had a problem like this.

2. Inserting user information into users table
Because mysqld_safe --skip-grant-tables里面是不能用grant的,于是想到了手动insert插入root用户:

**为了大家方便这里提供一些说明:第一个值是host,第二个为user这两项是必填项,password("my_password")这里进行密码的设置。MY_PASSWORD 就是新设的密码 ,而‘Y‘有28个。之后有1个enum和3个blob 能够为空,也就是这里的4个空字符,int类型有4个,默认值为0

INSERT intoUser VALUES('% ',' Root ',Password(' My_password '),' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' Y ',' y ', 'y ', ' y ',"',"',"',"',0,0,0,0)

The basic one here is to use password (' password ') at the 3rd field password. Since password in MySQL is to be encoded, it is not a direct string to save.

3, then kill all the MySQL process. After the normal restart of MySQL, you can log in with the root user


To the present, the problem of personal encounter is the total of these two, hope to you practical!!




Install MySQL 1045 and other errors under Windows Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.