Failed to start MySQL Community Server in Ubuntu

1. Install MySQL

This article is installed through APT, and the latest version installed is 5.7.21

(Note: The versions installed through APT are the latest versions. After installation through this method, the automatic startup has been configured, and the environment variables on the command line do not need to be configured manually.)

sudo apt-get install mysql-server

If it prompts that there are insufficient dependencies, run the following command to solve the dependency problem. If there is no dependency problem, there is no need to use this command.

sudo apt-get install -f

During the installation process, you will be prompted to enter the root user password twice.

Note: After installation in this way, the automatic startup has been configured, and the environment variables on the command line do not need to be configured manually.

After installation, the following directory will be created:

Database directory:/var/lib/mysql/

Configuration file: /usr/share/mysql (command and configuration file), /etc/mysql (such as: my.cnf)

Related commands: /usr/bin (mysqladmin mysqldump and other commands) and /usr/sbin

Startup script: /etc/init.d/mysql (directory of startup script file mysql)

-----------------

2. Encounter startup problems

sudo systemctl status mysql.service

I get the following message:

● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; disabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2021-03-02 11:32:34 IST; 58s ago
    Process: 3383 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)

Mar 02 11:32:34 avivilloz systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Mar 02 11:32:34 avivilloz systemd[1]: Stopped MySQL Community Server.
Mar 02 11:32:34 avivilloz systemd[1]: mysql.service: Start request repeated too quickly.
Mar 02 11:32:34 avivilloz systemd[1]: mysql.service: Failed with result 'exit-code'.
Mar 02 11:32:34 avivilloz systemd[1]: Failed to start MySQL Community Server.

Solution

 sudo apt-get purge mysql-server mysql-client mysql-common

sudo apt-get install mysql-server

Guess you like

Origin blog.csdn.net/sj349781478/article/details/132776407