programing

Windows에서 Ubuntu Linux 18.04 WSL: MariaDB 서비스 시작 실패

itsource 2022. 11. 23. 20:27
반응형

Windows에서 Ubuntu Linux 18.04 WSL: MariaDB 서비스 시작 실패

Linux WSL for Windows에 MariaDB 저장소 구성 도구를 처음 설치한 후(MariaDB 다운로드 페이지에서 설명)mysql소켓 에러가 있었습니다. netstat -apn | grep mysqlmysql 서비스가 정지되었음을 나타내는 아무것도 표시되지 않습니다.sudo apt list | grep *mysql-server*정상적으로 인스톨 되어 있는 것을 나타냅니다.mysql-server.

하지만 해보니sudo service mysql start명령줄은 다음과 같습니다.

 * Starting MariaDB database server mysqld                 [fail]

다음 방법을 시도했지만 모두 실패했고 동일한 답변을 얻었습니다.

  • 사용./etc/init.d/mysql start
  • 삭제 중/var/lib/mysql/ib_logfile0그리고./var/lib/mysql/ib_logfile1
  • 액세스 업그레이드/var/lib/mysql사용.chmod -R 777 /var/lib/mysql
  • 에서 모든 것을 삭제하다/var/lib/mysql/
  • 를 사용하여 포트 설정 변경port=1112/etc/my.cnf(Windows 쪽에 다른 mysql이 있기 때문에)
  • 에 추가 정보 입력/etc/my.cnf(설치 후 처음에 설정파일이 비어있었기 때문에basedir,datadir,socket,log_error,그리고.pid-file속성)
  • 괴로운systemctl대신service(Linux WSL이 를 사용하고 있기 때문에 실패.sysvinit대신systemd)

MariaDB 서비스를 시작하려면 어떻게 해야 합니까?감사해요.

WSL1에 당신의 문제(혹은 매우 유사한 문제)를 재현할 수 있습니다.WSL1을 사용하고 있는지 확인해 주시겠습니까?

2개의 클론 인스턴스를 스핀업했습니다(wsl --importUbuntu 20.04의 클린백업) -- WSL1과 WSL2에서 각각1개씩.아쉽게도 18.04는 가지고 있지 않지만, 같은 문제였으면 합니다.

WSL2에서는 모든 것이 정상적으로 동작했습니다.인스톨 순서(코멘트에 기재한 순서와 거의 일치하지만, 20.04분) 후에, 다음과 같이 할 수 있었습니다.

sudo service mariadb start

그리고 나서.sudo mysql -u root성공했습니다.

그러나 WSL1에서는 MariaDB 설치가 이상한 방법으로 실패하는 것 같습니다.생성되지 않습니다./etc/mysql/mariadb.cnf그 결과 빈칸으로 표시된 것이 나타납니다./etc/mysql/my.cnf에 대한 심볼 링크이기 때문에mariadb.cnf.

그래서 mariadb.cnf를 수동으로 작성했습니다.

sudo vi /etc/mysql/mariadb.cnf

내용 포함:

# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 0. "/etc/mysql/my.cnf" symlinks to this file, reason why all the rest is read.
# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.
#
# If the same option is defined multiple times, the last one will apply.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# If you are new to MariaDB, check out https://mariadb.com/kb/en/basic-mariadb-articles/

#
# This group is read both by the client and the server
# use it for options that affect everything
#
[client-server]
# Port or socket location where to connect
# port = 3306
socket = /run/mysqld/mysqld.sock

# Import all .cnf files from configuration directory
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/

이것은 단순히 디폴트입니다.mariadb.cnfWSL2 에 인스톨 하면 올바르게 작성됩니다.

서비스를 시작하려고 하면 누락된 에러가 발생하였습니다./etc/mysql/debian-start그 때문에, 같은 순서로 카피했습니다.

sudo vi /etc/mysql/debian-start

내용 포함:

#!/bin/bash
#
# This script is executed by "/etc/init.d/mariadb" on every (re)start.
#
# Changes to this file will be preserved when updating the Debian package.
#
# NOTE: This file is read only by the traditional SysV init script, not systemd.
#

source /usr/share/mysql/debian-start.inc.sh

# Read default/mysql first and then default/mariadb just like the init.d file does
if [ -f /etc/default/mysql ]; then
  . /etc/default/mysql
fi

if [ -f /etc/default/mariadb ]; then
  . /etc/default/mariadb
fi

MYSQL="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf"
MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
# Don't run full mysql_upgrade on every server restart, use --version-check to do it only once
MYUPGRADE="/usr/bin/mysql_upgrade --defaults-extra-file=/etc/mysql/debian.cnf --version-check"
MYCHECK="/usr/bin/mysqlcheck --defaults-file=/etc/mysql/debian.cnf"
MYCHECK_SUBJECT="WARNING: mysqlcheck has found corrupt tables"
MYCHECK_PARAMS="--all-databases --fast --silent"
MYCHECK_RCPT="${MYCHECK_RCPT:-root}"

## Checking for corrupt, not cleanly closed (only for MyISAM and Aria engines) and upgrade needing tables.

# The following commands should be run when the server is up but in background
# where they do not block the server start and in one shell instance so that
# they run sequentially. They are supposed not to echo anything to stdout.
# If you want to disable the check for crashed tables comment
# "check_for_crashed_tables" out.
# (There may be no output to stdout inside the background process!)

# Need to ignore SIGHUP, as otherwise a SIGHUP can sometimes abort the upgrade
# process in the middle.
trap "" SIGHUP
(
  upgrade_system_tables_if_necessary;
  check_root_accounts;
  check_for_crashed_tables;
) >&2 &

exit 0

그리고 나서.chmod 755 /etc/mysql/debian-start

그 후, voila:

sudo service mariadb restart

sudo mysql -u root

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 32
Server version: 10.5.8-MariaDB-1:10.5.8+maria~focal mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

지금까지의 순서를 생각하면, 「깨끗하게」를 다시 시작하기 위해서, 거의 모든 것을 날려 버리는 것을 추천합니다.

sudo apt remove mariadb-server
sudo apt autoremove
sudo rm -rf /etc/mysql
sudo rm -rf /var/lib/mysql
sudo rm -rf /usr/lib/mysql

그런 다음 mariadb-server를 다시 설치하고 위의 절차에 따라 올바른 파일을 만듭니다.

언급URL : https://stackoverflow.com/questions/65686836/ubuntu-linux-18-04-wsl-in-windows-mariadb-service-start-fails

반응형