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!

  • 相关阅读:
    《我所理解的生活》—读书总结
    《给你一个团队,你能怎么管?》—读书总结
    关于投资那点儿事
    《30岁前的每一天》—读书总结
    《书都不会读,你还想成功》-读书总结
    解决问题—麦肯锡方法:解决问题的七个步骤
    解决问题—基本流程
    关于接入新浪微博第三方登录
    搭建Spring、Spring MVC、Mybatis和Freemarker
    Eclipse+Maven创建webapp项目<二>
  • 原文地址:https://www.cnblogs.com/liawne/p/9276939.html
Copyright © 2011-2022 走看看