• 【转载】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!

  • 相关阅读:
    模块在insmod之后无法rmmod问题
    FL2440驱动添加(2): RTC(Real time clock)
    虚拟机安装CentOS6.3两个问题
    内核移植和文件系统制作(3)Ramdisk简介和常见问题
    FL2440驱动添加(1):hello world 驱动模块添加
    内核移植和文件系统制作(2):linux内核最小系统和initramfs文件系统
    内核移植和文件系统制作(1):根文件系统制作总结
    mysql 5.7.16多源复制
    mysql 5.7安装脚本
    二进制方式快速安装MySQL数据库命令集合
  • 原文地址:https://www.cnblogs.com/liawne/p/9276939.html
Copyright © 2020-2023  润新知