Ubuntu 18.0.4 installs mysql and solves ERROR 1698 (28000): Access denied for user ''root''@''localhost''

Ubuntu 18.0.4 installs mysql and solves ERROR 1698 (28000): Access denied for user ''root''@''localhost''

Preface

I recently learned Linux, and then changed Win to Ubuntu. The previously installed mysql is no longer usable. Now I will install mysql on ubuntu18.0.4 and record the problems encountered as follows:

Download and install mysql

Execute the statement sudo apt-get install mysql-server

insert image description here

Because I have already installed it here, this will happen. You can view the installed version through mysql --version.

Login to mysql

Execute the statement mysql -u root -p

-u is user and -p is port. When logging in, ERROR 1698 (28000): Access denied for user 'root'@'localhost' occurs. This should be caused by forgetting the password or not remembering the initialization password when we installed it before:

insert image description here

Here's how to solve this problem:

1. Enter the command sudo vim /etc/mysql/debian.cnf and we will see the following information:

insert image description here

The debian-sys-maint account is the MySQL user automatically generated by the system when MySQL is installed, and the corresponding password is the password of this user.

2. Log in to the account debian-sys-maint:

mysql -u debian-sys-maint -p can log in to mysql:

insert image description here

3. Change the root account password:

Enter the command use mysql;

Then enter the command:

UPDATE user SET authentication_string=PASSWORD('The password you want to set') where USER='root'; This is to set the password for the root account.

Then enter the command quit to exit mysql, and execute the restart mysql command sudo service mysql restart;

Then log in to mysql, and when executing mysql -u root -p, I still get an error: ERROR 1524 (HY000): Plugin 'msyql_native_password' is not loaded

insert image description here

At this time, the password has actually been changed successfully. The field of plugin root is auth_socket, which needs to be changed.

4. Modify plugin:

Continue to log in using debian-sys-maint account;

Execute the command:

use mysql

Execute the command:

select user,plugin from user;

Then execute the command:

update user set authentication_string =password('the password you want to set'),plugin='mysql_native_password' where user='root';

Finally, exit and restart mysql:

insert image description here

Summarize

The above is what I introduced to you about installing MySQL in Ubuntu 18.0.4 and solving ERROR 1698 (28000): Access denied for user 'root'@'localhost'. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • MySQL bypasses granting information_schema objects and reports ERROR 1044 (4200) error
  • mysql databasemysql: [ERROR] unknown option ''--skip-grant-tables''
  • How to solve the 10060 unknow error when Navicat remotely connects to MySQL
  • ERROR 2002 (HY000): Can't connect to local MySQL server through socket ''/tmp/mysql.sock''
  • Solution to MySQL server login error ERROR 1820 (HY000)
  • Solve MySQL startup error: ERROR 2003 (HY000): Can't connect to MySQL server on ''localhost'' (10061)

<<:  Detailed explanation of the 10061 unknown error when using Navicat to connect to a remote Linux MySQL database

>>:  Node implements search box for fuzzy query

Recommend

JavaScript regular verification password strength implementation method

exhibit design Password strength analysis The pas...

HTML+VUE paging to achieve cool IoT large screen function

Effect demo.html <html> <head> <me...

Detailed tutorial on distributed operation of jmeter in docker environment

1. Build the basic image of jmeter The Dockerfile...

20 CSS coding tips to make you more efficient (sorted)

In this article, we would like to share with you ...

Detailed explanation of destructuring assignment syntax in Javascript

Preface The "destructuring assignment syntax...

Docker link realizes container interconnection

Table of contents 1.1. Network access between con...

Example of implementing the Graphql interface in Vue

Note: This article is about the basic knowledge p...

What to do if you forget the initial password of MySQL on MAC

The solution to forgetting the initial password o...

Use crontab to run the script of executing jar program regularly in centOS6

1. Write a simple Java program public class tests...

Analysis of mysql view functions and usage examples

This article uses examples to illustrate the func...

JavaScript Closures Explained

Table of contents 1. What is a closure? 1.2 Memoi...

Comparing Document Locations

<br />A great blog post by PPK two years ago...