mariadb 10.1,mysqld.sock文件在每次系统重新启动时丢失

8wigbo56  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(472)

我需要mariadb 10.1来满足我的要求。每次我重新启动系统,我得到以下错误。
错误2002(hy000):无法通过套接字'/var/run/mysqld/mysqld.sock'(2“没有这样的文件或目录”)连接到本地mysql服务器
我尝试了一些在互联网上找到的解决方案,但似乎没有一个是有效的
尝试手动创建所有者为mysql的sock文件。
尝试重新启动mysql服务器,出现错误。
正在运行的mysql服务状态

mariadb.service - MariaDB 10.1.30 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: failed (Result: timeout) since Wed 2018-01-17 11:09:45 IST; 3min 43s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 1143 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 982 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemc
  Process: 974 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 967 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
 Main PID: 1143 (code=exited, status=0/SUCCESS)

Jan 17 11:09:42 infibeam-vostro-006 mysqld[1143]: 2018-01-17 11:09:42 140110739585792 [Note] /usr/sbin/mysqld: Normal shutdown
Jan 17 11:09:42 infibeam-vostro-006 mysqld[1143]: 2018-01-17 11:09:42 140110739585792 [Note] Event Scheduler: Purging the queue. 0 events
Jan 17 11:09:43 infibeam-vostro-006 mysqld[1143]: 2018-01-17 11:09:43 140109819123456 [Note] InnoDB: FTS optimize thread exiting.
Jan 17 11:09:43 infibeam-vostro-006 mysqld[1143]: 2018-01-17 11:09:43 140110739585792 [Note] InnoDB: Starting shutdown...
Jan 17 11:09:43 infibeam-vostro-006 mysqld[1143]: 2018-01-17 11:09:43 140110739585792 [Note] InnoDB: Waiting for page_cleaner to finish flushin
Jan 17 11:09:45 infibeam-vostro-006 mysqld[1143]: 2018-01-17 11:09:45 140110739585792 [Note] InnoDB: Shutdown completed; log sequence number 82
Jan 17 11:09:45 infibeam-vostro-006 mysqld[1143]: 2018-01-17 11:09:45 140110739585792 [Note] /usr/sbin/mysqld: Shutdown complete
Jan 17 11:09:45 infibeam-vostro-006 systemd[1]: Failed to start MariaDB 10.1.30 database server.
Jan 17 11:09:45 infibeam-vostro-006 systemd[1]: mariadb.service: Unit entered failed state.
Jan 17 11:09:45 infibeam-vostro-006 systemd[1]: mariadb.service: Failed with result 'timeout'

唯一可行的解决方案是从系统中清除mysql并重新安装它。

sudo apt-get --purge remove "mysql*"
sudo apt update -y
sudo apt install -y mariadb-server
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

但下次我启动系统时,它会给出相同的错误sock文件丢失。有解决办法吗。文件丢失有具体原因吗?
谢谢你。

ugmeyewa

ugmeyewa1#

假设您已经启用了mysql作为服务(看起来是这样),那么我建议您 service mysql status 查看服务是否运行正常(如果没有,它将显示一些错误消息)。

相关问题