Ubuntu 18.04 does not prompt for password when installing MySQL and how to solve it

Ubuntu 18.04 does not prompt for password when installing MySQL and how to solve it

The installation of MySQL 5.7 on Ubuntu 1804 is introduced in detail.

Execute the command to install MySQL

sudo apt install mysql-server
sudo apt install mysql-client

After installation, check whether it is started:

sudo ps aux | grep mysql

If it has been started, you can see the corresponding information after executing the above command. If it has not been started, you can execute the following command to start mysql:

sudo service mysql start

In addition, you will need to restart MySQL later. The commands to restart and shut down MySQL are:

sudo service mysql restart
sudo service mysql stop

After ensuring that mysql is started successfully, you can log in to mysql. However, there is no step to prompt for a username and password during the installation process. At this time, you can view the default username and password in '/etc/mysql/debian.cnf':

sudo cat /etc/mysql/debian.cnf 

insert image description here

You can log in to mysql with user and password:

mysql -udebian-sys-maint -pZBms1EM5icCfeePV 

insert image description here

However, the default username and password are hard to remember. You can use the following SQL statement to add a user named my_name with a password my_password:

show databases;
use mysql;
update user set authentication_string=PASSWORD("my_password") where user='my_name';
update user set plugin="mysql_native_password";
flush privileges;
exit; 

insert image description here

After adding the user, restart mysql and log in with my_name.

Summarize

The above is the problem and solution of not prompting for password when installing MySQL in Ubuntu 18.04. I hope it will be helpful to everyone. 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:
  • How to install JDK and Mysql on Ubuntu 18.04 Linux system
  • Complete tutorial on installing Apache, MySQL, PHP, LAMP on Ubuntu 18.04
  • Detailed explanation of the process of installing MySQL on Ubuntu 18.04.4

<<:  MySQL compressed package version zip installation configuration method

>>:  Detailed tutorial for installing mysql 8.0.12 under Windows

Recommend

Detailed explanation of Vue-router nested routing

Table of contents step 1. Configure routing rules...

Summary of MySQL date and time functions (MySQL 5.X)

1. MySQL gets the current date and time function ...

HTML table tag tutorial (8): background image attribute BACKGROUND

Set a background image for the table. You can use...

Design Theory: Hierarchy in Design

<br />Original text: http://andymao.com/andy...

Three methods of automatically completing commands in MySQL database

Note: The third method is only used in XSell and ...

Methods for optimizing Oracle database with large memory pages in Linux

Preface PC Server has developed to this day and h...

A brief analysis of the differences between px, rem, em, vh, and vw in CSS

Absolute length px px is the pixel value, which i...

An article to understand the usage of typeof in js

Table of contents Base Return Type String and Boo...

Optimizing the slow query of MySQL aggregate statistics data

Written in front When we operate the database in ...

What can I use to save you, my table (Haiyu Blog)

Tables once played a very important role in web p...

Do you know how many connections a Linux server can handle?

Preface First, let's see how to identify a TC...

How to change password and set password complexity policy in Ubuntu

1. Change password 1. Modify the password of ordi...