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

Using jQuery to implement the carousel effect

This article shares the specific code for impleme...

Basic statements of MySQL data definition language DDL

MySQL DDL statements What is DDL, DML. DDL is dat...

Preventing SQL injection in web projects

Table of contents 1. Introduction to SQL Injectio...

Tips on setting HTML table borders

For many people who are new to HTML, table <ta...

Explanation of the problem that JavaScript strict mode does not support octal

Regarding the issue that JavaScript strict mode d...

VUE introduces the implementation of using G2 charts

Table of contents About G2 Chart use Complete cod...

Detailed explanation of nodejs built-in modules

Table of contents Overview 1. Path module 2. Unti...

Summary of four ways to introduce CSS (sharing)

1. Inline reference: used directly on the label, ...

CSS3 sample code to achieve element arc motion

How to use CSS to control the arc movement of ele...

JavaScript implements page scrolling animation

Table of contents Create a layout Add CSS styles ...

Usage of mysql timestamp

Preface: Timestamp fields are often used in MySQL...

Summary of HTML knowledge points for the front end (recommended)

1. HTML Overview htyper text markup language Hype...

MySQL fuzzy query usage (regular, wildcard, built-in function)

Table of contents 1. MySQL wildcard fuzzy query (...