Failed to start MySQL Community Server in Ubuntu

一、安装MySQL

本文是通过APT方式安装,安装的最新版本是5.7.21

(注意:通过APT方式安装的版本都是现在最新的版本,通过这种方式安装好之后开机自启动都已经配置好,和命令行上的环境变量,无需手动配置。)

复制代码
sudo apt-get install mysql-server

如果提示依赖不足,运行下面命令解决依赖问题,如果没出现依赖问题,那么就不需要使用此命令

复制代码
sudo apt-get install -f

安装过程会提示输入两次root用户密码

说明:通过这种方式安装好之后开机自启动都已经配置好,和命令行上的环境变量,无需手动配置。

安装好之后会创建如下目录:

数据库目录:/var/lib/mysql/

配置文件:/usr/share/mysql(命令及配置文件) ,/etc/mysql(如:my.cnf)

相关命令:/usr/bin(mysqladmin mysqldump等命令) 和/usr/sbin

启动脚本:/etc/init.d/mysql(启动脚本文件mysql的目录)


二.遇到启动问题

复制代码
sudo systemctl status mysql.service

我得到以下信息:

复制代码
● 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.

解决方法

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

sudo apt-get install mysql-server

相关推荐
守望时空3313 分钟前
Linux挂载NTFS分区指南
linux
shan~~1 小时前
linux达梦数据库操作
linux·数据库·chrome
liliangcsdn1 小时前
LLM时代基于unstructured解析非结构化pdf
linux·服务器·数据分析
Codigger官方2 小时前
Linux 基金会牵头成立 React 基金会:前端开源生态迎来里程碑式变革
linux·前端·react.js
武文斌772 小时前
项目学习总结:LVGL图形参数动态变化、开发板的GDB调试、sqlite3移植、MQTT协议、心跳包
linux·开发语言·网络·arm开发·数据库·嵌入式硬件·学习
爱吃喵的鲤鱼2 小时前
仿mudou——Connection模块(连接管理)
linux·运维·服务器·开发语言·网络·c++
让子弹飞022 小时前
永久解决ubuntu网络连接问题
linux·运维·ubuntu
郝学胜-神的一滴2 小时前
使用Linux的read和write系统函数操作文件
linux·服务器·开发语言·数据库·c++·程序人生·软件工程
七七七七074 小时前
【Linux 系统】打开文件和文件系统
linux·运维·spring
DeeplyMind4 小时前
第二章:模块的编译与运行-7 Loading and Unloading Modules
linux·驱动开发