search
HomeDatabaseMysql TutorialSolve the problem of ERROR 1045 (28000) when logging in when installing mysql5.7.17 on ubuntu16.04 (picture)

This article mainly introduces how to solve the problem of ERROR 1045 (28000): Access denied for user 'root'@'localhost' when logging in after installing mysql5.7.17 on ubuntu 16.04. Friends who need it can refer to it

1. Problem description

Today, in order to practice sql, the author installed MySQL on ubuntu16.04. The author searched the Internet for the steps to install mysql on ubuntu16.04 and followed the steps step by step. However, what I couldn't understand was that the Internet said that during the installation process of mysql, a window for entering the password would pop up. However, during the installation process, the author No window pops up and no error is reported.

When the author was logging in to mysql, the problem occurred, as shown in the picture:

Solve the problem of ERROR 1045 (28000) when logging in when installing mysql5.7.17 on ubuntu16.04 (picture)

As shown in the picture, the author tried multiple input methods, but All got the same sad result, ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

In order to understand this problem, the author went online again Extensive search, from

MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)the real reason

this The link found the cause of the problem. However, the author has little knowledge and does not understand it very well, but I still want to solve the problem, so I changed the topic and searched. Since the author does not know the password, then I used "Forgot root password" " is the search object, so I found

Reset MySQL 5.7 password under ubuntu 16.04 (forgot password)

However, at this point, the author still cannot solve the problem because

Solve the problem of ERROR 1045 (28000) when logging in when installing mysql5.7.17 on ubuntu16.04 (picture)

The author's configuration file/etc/mysql/my.cnfThere is no [mysqld] section under it. Sorry

Later, the author struggled on the Internet again After searching for a long time, I finally found the [mysqld] paragraph in the file /etc/mysql/mysql.conf.d/mysqld.cnf . I was so moved.

Solve the problem of ERROR 1045 (28000) when logging in when installing mysql5.7.17 on ubuntu16.04 (picture)

At this point, the author believes that mysql5.7.17 changed the original meaning of my.cnf to mysqld.cnf and placed it under the /etc/mysql/mysql.conf.d/ path.

At this point, the problem I encountered has finally been solved. I am really happy!

The author below introduces his own mysql installation process and the specific problem solving process.

2. Mysql installation process

Enter the commands in the ubuntu terminal:

 $ sudo apt update
 $ sudo apt-get install mysql-server mysql-client

3. Problem solving process

1. Open the /etc/mysql/mysql.conf.d/mysqld.cnf file and the command is as follows

 $ sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

2. Find [mysqld ] section, and add a line "skip-grant-tables", as shown below,

Solve the problem of ERROR 1045 (28000) when logging in when installing mysql5.7.17 on ubuntu16.04 (picture)

3. Restart the mysql service, enter the mysql management command line with a blank password, and switch to mysql Library, the operation command is as follows,

 $ mysql
 Welcome to the MySQL monitor. Commands end with ; or \g. 
 mysql> use mysql
 Reading table information for completion of table and column names
 You can turn off this feature to get a quicker startup with -A
 Database changed
 mysql> update mysql.user set authentication_string=password('newpass') where user='root' and Host ='localhost';
 Query OK, 1 row affected, 1 warning (0.00 sec)
 Rows matched: 1 Changed: 1 Warnings: 1
 mysql> update user set plugin="mysql_native_password"; 
 Query OK, 0 rows affected (0.00 sec)
 Rows matched: 3 Changed: 0 Warnings: 0
 mysql> flush privileges;
 Query OK, 0 rows affected (0.01 sec)
 mysql> quit;
 Bye

4. Return to sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf, comment or delete the line "skip-grant-tables" just added Lose.

5. Restart the mysql service sudo service mysql restart, log in with the new password, and the modification is successful.

 $ mysql -u root -p new_pass 
 Welcome to the MySQL monitor. Commands end with ; or \g. 
 mysql>

Related articles

About the problem that ubuntu 16 cannot install php5.6

Enable php debugging mode under Ubuntu and display error messages

The mongodb extension operation command for installing PHP under Ubuntu

The above is the detailed content of Solve the problem of ERROR 1045 (28000) when logging in when installing mysql5.7.17 on ubuntu16.04 (picture). For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP Fatal error: Call to undefined method PDO::prepare() in的解决方法PHP Fatal error: Call to undefined method PDO::prepare() in的解决方法Jun 22, 2023 pm 06:40 PM

PHP作为一种流行的Web开发语言,已经被使用了很长时间。PHP中集成的PDO(PHP数据对象)类是我们在开发Web应用程序过程中与数据库进行交互的一种常用方法。但是,一些PHP开发者经常遇到的问题是,当使用PDO类与数据库进行交互时,他们会收到这样的错误:PHPFatalerror:CalltoundefinedmethodPDO::prep

解决C++代码中出现的“error: incomplete type is not allowed”问题解决C++代码中出现的“error: incomplete type is not allowed”问题Aug 26, 2023 pm 08:54 PM

解决C++代码中出现的“error:incompletetypeisnotallowed”问题在C++的编程过程中,有时候会遇到一些编译错误,其中一个常见的错误是“error:incompletetypeisnotallowed”。这个错误通常是由于在使用不完整的类型进行操作时引起的。本文将介绍这个错误的原因,并提供几种解决方法。首先,我

在Vue应用中使用axios时出现“Uncaught (in promise) Error: Request failed with status code 500”怎么办?在Vue应用中使用axios时出现“Uncaught (in promise) Error: Request failed with status code 500”怎么办?Jun 24, 2023 pm 05:33 PM

在Vue应用中使用axios是十分常见的,axios是一种基于Promise的HTTP客户端,可以用于浏览器和Node.js。在开发过程中,有时会出现“Uncaught(inpromise)Error:Requestfailedwithstatuscode500”的错误提示,对于开发者来说,这个错误提示可能有些难以理解和解决。本文将会探讨这

0271:real time clock error开不开机怎么办0271:real time clock error开不开机怎么办Mar 13, 2023 am 11:30 AM

“0271:real time clock error”开不开机的解决办法:1、按一下F1,在出现的界面中,将选项栏转到第三项“Date/Time”;2、将系统时间手动修改成现在的时间;3、按F10,在弹出的对话框中,选择yes;4、重新打开笔记本即可正常开机。

解决C++代码中出现的“error: expected initializer before 'datatype'”问题解决C++代码中出现的“error: expected initializer before 'datatype'”问题Aug 25, 2023 pm 01:24 PM

解决C++代码中出现的“error:expectedinitializerbefore'datatype'”问题在C++编程中,有时候我们在编写代码时会遇到一些编译错误,其中一种常见的错误是“error:expectedinitializerbefore'datatype'”。这个错误通常在变量声明或函数定义中发生,可能导致程序无法正确编译或

如何解决PHP Warning: fopen(): failed to open stream: No such file or directory如何解决PHP Warning: fopen(): failed to open stream: No such file or directoryAug 19, 2023 am 10:44 AM

如何解决PHPWarning:fopen():failedtoopenstream:Nosuchfileordirectory在使用PHP开发过程中,我们经常会遇到一些文件操作的问题,其中之一就是"PHPWarning:fopen():failedtoopenstream:Nosuchfileordirectory

PHP Fatal error: Call to undefined function mysqli_connect()的解决方法PHP Fatal error: Call to undefined function mysqli_connect()的解决方法Jun 23, 2023 am 09:40 AM

在使用PHP编写Web应用程序时,经常会使用MySQL数据库来存储数据。PHP提供了一种与MySQL数据库进行交互的方法,称为MySQLi。然而,有时在使用MySQLi时,会遇到一个错误信息,如以下所示:PHPFatalerror:Calltoundefinedfunctionmysqli_connect()这个错误信息意味着PHP无法找到my

PHP Fatal error: Call to a member function fetch()的解决方法PHP Fatal error: Call to a member function fetch()的解决方法Jun 23, 2023 am 09:36 AM

在使用PHP进行web应用开发时,很多时候会需要使用数据库。而在使用数据库时,错误提示是非常常见的事情。其中,PHPFatalerror:Calltoamemberfunctionfetch()是一种比较常见的错误,它会在使用PDO查询数据库时出现。那么,这个错误是怎么引起的,以及如何解决呢?本文将为大家详细阐述。一、错误产生原

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools