Digital Ocean CentOS7服务器,无法--skip-grant-tables或重启mysql

Oli*_*ams 9 mysql centos mariadb centos7

前几天搭建了一个Digital Ocean Droplet(服务器),需要访问mysql。在我尝试过的过程中,没有 root 密码有效。但是这个命令:

service mysql[d] stop
Run Code Online (Sandbox Code Playgroud)

不起作用。显然我应该发出这个命令:

sudo systemctl stop mariadb.service
Run Code Online (Sandbox Code Playgroud)

但这导致

Failed to stop mariadb.service: Unit mariadb.service not loaded.
Run Code Online (Sandbox Code Playgroud)

此外,这个命令

mysqld_safe --skip-grant-tables --skip-networking & mysql -u root
Run Code Online (Sandbox Code Playgroud)

结果在这些响应中:

sudo: mysqld_safe: command not found
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[1]+  Exit 1   sudo mysqld_safe --skip-grant-tables --skip-networking
Run Code Online (Sandbox Code Playgroud)

我以 root 身份登录到服务器;我该怎么做?

Ant*_*ito 10

尝试

yum remove mysql
Run Code Online (Sandbox Code Playgroud)

然后试试

service mariadb restart
Run Code Online (Sandbox Code Playgroud)

然后看看从

service mariadb status
Run Code Online (Sandbox Code Playgroud)

您应该看到它正在运行,然后您早期尝试过的命令应该可以工作

如果

 yum remove mysql
Run Code Online (Sandbox Code Playgroud)

不工作 试试

 chkconfig mysql off
Run Code Online (Sandbox Code Playgroud)

重新启动并尝试再次启动 maria。