• linux mysql启动错误


    启动mysql时报错:
    Starting mysqld daemon with databases from /var/lib/mysql
    STOPPING server from pid file /var/run/mysqld/mysqld.pid
    071112 00:22:06 mysqld ended
    查看日志:
    #less /var/log/mysqld.log
    其中有一段如下:
    
    071112 0:22:06 [ERROR] /usr/local/mysql/bin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2)
    071112 0:22:06 [ERROR] Can't start server: can't create PID file: No such file or directory
    071112 00:22:06 mysqld ended
    #cd /var/run/
    #ls
    
    mysqld目录不存在,创建它:  -------------------------------------------这是重点
    
    #mkdir /var/run/mysqld
    #cd /var/run/mysqld
    
    创建文件mysqld.pid:
    
    #touch mysqld.pid
    #cd..
    #chown -R mysql mysqld .
    #cd /usr/local/mysql/
    #bin/mysqld_safe --user=mysql &
    nohup: ignoring input and redirecting stderr to stdout
    Starting mysqld daemon with databases from /var/lib/mysql
    能正常启动
    #bin/mysqladmin -u root password root
    又出错
    [root@localhost mysql]# bin/mysqladmin -u root password root
    bin/mysqladmin: connect to server at 'localhost' failed
    error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
    Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
    [root@localhost mysql]# bin/mysql -u root -p
    Enter password:
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
    分析:是/tmp/mysql.sock 不存在
    
    # cd /var/lib/mysql/
    由于mysql 默认的mysql.sock 是在/var/lib/mysql/mysql.sock,创建符号连接:
    
    # ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock      -----------------------------这是重点
    # bin/mysql -u root
    Welcome to the MySQL monitor. Commands end with ; or g.
    Your MySQL connection id is 1
    Server version: 5.0.45 MySQL Community Server (GPL)
    Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
    mysql>
  • 相关阅读:
    [转] Immutable 常用API简介
    [转] 组件库按需加载 借助babel-plugin-import实现
    [转] react-router4 + webpack Code Splitting
    [转] React Hot Loader 3 beta 升级指南
    [转] 如何写好.babelrc?Babel的presets和plugins配置解析
    [转] webpack热更新配置小结
    [转] 学会fetch的用法
    [转] webpack3.0踩坑:postcss-loader的使用
    [转] 详解webpack-dev-server的使用
    webpack 使用环境变量
  • 原文地址:https://www.cnblogs.com/xiao0/p/2670628.html
Copyright © 2020-2023  润新知