zoukankan      html  css  js  c++  java
  • 【转载】mysqld_safe Directory ‘/var/run/mysqld’ for UNIX socket file don’t exists.

    This is about resetting the MySQL 5.7 root password in Ubuntu 16.04 LTS

    You probably tried something like this:

    sudo service mysql stop
    mysqld_safe --skip-grant-tables &

    And then got something like this (stangely, exists is misspelled in the output):

    [1] 5599
    2018-03-02T21:36:41.292413Z mysqld_safe Logging to syslog.
    2018-03-02T21:36:41.294798Z mysqld_safe Logging to '/var/log/mysql/error.log'.
    2018-03-02T21:36:41.296902Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.

    Then you tried to find the socket (takes a while):

    sudo find / -type s

    And /var/run/mysqld does not exist.

    So you start mysql again and search and now it does exist!

    sudo service mysql start
    sudo find / -type s
    
    [output:]
    /run/mysqld/mysqld.sock
    /run/dbus/system_bus_socket
    /run/acpid.socket
    /run/snapd-snap.socket
    ...

    My guess is that mysql_safe can’t create the directory (which appears to be dynamically created when mysql starts). Solution:

    sudo mkdir /var/run/mysqld 
    sudo chown mysql:mysql /var/run/mysqld

    Now run:

    sudo service mysql stop
    mysqld_safe --skip-grant-tables &
    mysql -uroot mysql

    When you get to the mysql prompt (don’t forget to change your pw before copy/pasting!!!):

    UPDATE mysql.user SET authentication_string=PASSWORD('YOURNEWPASSWORD'), plugin='mysql_native_password' WHERE User='root' AND Host='%';
    
    exit;

    then

    sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown
    sudo service mysql start

    OTHER SOLUTION (means restarting MySQL a couple times!):

    Note: in MySQL 5.7 you may find that my.cnf actually references config files elsewhere:

    !includedir /etc/mysql/conf.d/
    !includedir /etc/mysql/mysql.conf.d/

    So in my case:

    sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

    Under [mysqld] add:

    skip-grant-tables

    Close the file and restart mysql, then…

    sudo service mysql restart
    sudo mysql -uroot mysql
    (use query above...)

    Edit mysqld.conf again, remove the line, then restart MySQL

    sudo service mysql restart

    Good luck!

  • 相关阅读:
    在Eclipse中指定JDK
    VMware桥接模式下主机和和虚机间互相ping不通的处理方法
    CentOS7系列--10.1CentOS7中的GNOME桌面环境
    CentOS7系列--5.3CentOS7中配置和管理Kubernetes
    CentOS7系列--5.2CentOS7中配置和管理Docker
    CentOS7系列--5.1CentOS7中配置和管理KVM
    CentOS7系列--4.1CentOS7中配置DNS服务
    CentOS7系列--3.2CentOS7中配置iSCSI服务
    移动web开发(一)——移动web开发必备知识
    文章索引
  • 原文地址:https://www.cnblogs.com/liawne/p/9276939.html
Copyright © 2011-2022 走看看