zoukankan      html  css  js  c++  java
  • MySQL [ERROR] Table 'mysql.user' doesn't exist

    问题描述:

    在安装MYsql时,/etc/init.d/mysqld start时报错:

    [root@master data]# /etc/init.d/mysqld start
    Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/master.pid).

    解决步骤:

    1、检查安装MYSQL时的脚本,及指定的文件

    2、查看mariadb.log发现相关错误:

    [root@master init.d]# cd /var/log/mariadb
    [root@master mariadb]# ls
    mariadb.log

    具体错误为:[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist。下面是该错误的描述及其解决办法。

    #查看当前的my.cnf配置文件

    [root@master mariadb]#  more /etc/my.cnf |grep -v ^#
    [mysqld]
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    symbolic-links=0
    
    [mysqld_safe]
    log-error=/var/log/mariadb/mariadb.log
    pid-file=/var/run/mariadb/mariadb.pid
    
    !includedir /etc/my.cnf.d

    #由于编译安装时指定的路径为/mnt/mysql/data以及mysql_install_db时指定的datadir也为/mnt/mysql/data:

    /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/mnt/mysql/data --user=mysql

    而my.cnf为指定的路径为

    /var/lib/mysql

    #因此修改datadir至正确路径:

    [root@master mariadb]#  more /etc/my.cnf |grep -v ^#
    [mysqld]
    datadir=/mnt/mysql/data
    socket=/var/lib/mysql/mysql.sock
    symbolic-links=0
    [mysqld_safe]
    log-error=/var/log/mariadb/mariadb.log
    pid-file=/var/run/mariadb/mariadb.pid
    
    !includedir /etc/my.cnf.d

    [root@master mariadb]# service mysqld start
    Starting MySQL. SUCCESS!

  • 相关阅读:
    VMware coding Challenge: Coin Toss Betting
    Lintcode: k Sum II
    Lintcode: Interleaving Positive and Negative Numbers
    Lintcode: Insert Node in a Binary Search Tree
    Amazon OA
    Leetcode: Best Time to Buy and Sell Stock IV
    Leetcode: Reverse Words in a String II
    Leetcode: Repeated DNA Sequence
    Leetcode: Rotate Array
    VMware coding Challenge:Date of Weekday
  • 原文地址:https://www.cnblogs.com/yfb918/p/10635496.html
Copyright © 2011-2022 走看看