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

Negative distance (empathy) - iterative process of mutual influence

Negative distance refers to empathy. Preface (rai...

CentOS8 - bash: garbled characters and solutions

This situation usually occurs because the Chinese...

Box-shadow and drop-shadow to achieve irregular projection example code

When we want to add a shadow to a rectangle or ot...

How to Rename Multiple Files at Once in Linux

Preface In our daily work, we often need to renam...

Solution to MySQL Chinese garbled characters problem

1. The Chinese garbled characters appear in MySQL...

Summary of several commonly used CentOS7 images based on Docker

Table of contents 1 Install Docker 2 Configuring ...

CocosCreator Getting Started Tutorial: Network Communication

Network Communication Overview When developing an...

How to configure redis sentinel mode in Docker (on multiple servers)

Table of contents Preface condition Install Docke...

Difference between querySelector and getElementById methods in JS

Table of contents 1. Overview 1.1 Usage of queryS...

The use of FrameLayout in six layouts

Preface In the last issue, we explained LinearLay...

Deploy Nginx+Flask+Mongo application using Docker

Nginx is used as the server, Mongo is used as the...

Simple steps to configure Nginx reverse proxy with SSL

Preface A reverse proxy is a server that receives...

Ideas and codes for implementing Vuex data persistence

What is vuex vuex: is a state manager developed s...