在 ubuntu 16.04 上安装 mysql 服务器的问题 [英] Issue installing mysql server on ubuntu 16.04

查看:45
本文介绍了在 ubuntu 16.04 上安装 mysql 服务器的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 ubuntu 16.04 上安装 mysql 服务器,但是当我尝试执行命令时:sudo mysql_secure_installation.我收到错误消息:

I trying to install mysql server on ubuntu 16.04, but when I tried to execute the command: sudo mysql_secure_installation. I am getting the error message:

ERROR 2002 (HY000): 无法通过套接字连接到本地 MySQL 服务器'/var/run/mysqld/mysqld.sock' (2).

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2).

刚试过:

sudo apt install mysql-server mysql-client

这是我安装的sql版本:(mysql --version):

This is my sql version installed: (mysql --version):

mysql Ver 14.14 Distrib 5.7.12,用于 Linux (x86_64) 使用 EditLine包装器

mysql Ver 14.14 Distrib 5.7.12, for Linux (x86_64) using EditLine wrapper

我的机器上好像安装了mysql.

It looks like the mysql was installed on my machine.

我第一次安装mysql服务器,安装程序问我用户root密码,但是第二次,安装程序不问我这个凭据,然后如果我输入命令:mysql_secure_installation,我遇到了同样的问题:

The fist time I installed mysql server, the installer ask me for the user root password, but the second time, the installer don't ask me for this credentials, and then if I put the command: mysql_secure_installation, I am getting the same issue:

ERROR 2002 (HY000): 无法通过套接字连接到本地 MySQL 服务器'/var/run/mysqld/mysqld.sock' (2).

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2).

我也尝试在没有客户端的情况下单独安装mysql服务器,问题是一样的.我尝试 remove.purge 并重新安装 mysql,但我无法使用 mysql,我不知道发生了什么.

Also I tried to install alone the mysql server without the client, and the issue is the same. I tried to remove.purge and reinstall mysql, but I wasn't able to get working mysql, I don't know what is happening.

推荐答案

您的 linux 机器上似乎没有运行 mysql 服务.您可以使用 systemctl

It looks like mysql service is not running on your linux machine. You can check the whether the service is running or not using systemctl

systemctl status mysql

如果服务没有运行,您可以使用 systemctl

If the service is not running you can start the service using systemctl

sudo systemctl start mysql

但这只会为当前会话启动服务.如果您重新启动机器,您必须再次启动 mysql 服务器.要在重新启动时自动启动服务,请执行

But this will start the service for the current session only. If you reboot the machine you have to again start the mysql server. To auto start the service on reboot execute

sudo systemctl enable mysql

这篇关于在 ubuntu 16.04 上安装 mysql 服务器的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆