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

How to declare a cursor in mysql

How to declare a cursor in mysql: 1. Declare vari...

Detailed steps to install JDK and Tomcat in Linux environment

Table of contents 1. Install JDK Manual Installat...

How to solve the timeout during pip operation in Linux

How to solve the timeout problem when pip is used...

Mini Programs use Mini Program Cloud to implement WeChat payment functions

Table of contents 1. Open WeChat Pay 1.1 Affiliat...

Docker setting windows storage path operation

When installing Docker on Windows 10, after selec...

Linux kernel device driver kernel debugging technical notes collation

/****************** * Kernel debugging technology...

How to design the homepage of Tudou.com

<br />I have been working in front-end for s...

A brief discussion on HTML ordered lists, unordered lists and definition lists

Ordered List XML/HTML CodeCopy content to clipboa...

Docker custom network container interconnection

Table of contents Preface –link Custom Network As...

Example code for implementing dotted border scrolling effect with CSS

We often see a cool effect where the mouse hovers...