MySQL [ERROR] Table 'mysql.user' doesn't exist,mysql.userexist

來源:互聯網
上載者:User

MySQL [ERROR] Table 'mysql.user' doesn't exist,mysql.userexist

    一次源碼新裝的mysql,由於沒有複製my-default.cnf到/etc/my.cnf位置,在啟動mysql的時候碰到了無法開啟mysql.user表的錯誤。具體錯誤為:[ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist。下面是該錯誤的描述及其解決辦法。

 

1、現象描述
[root@HKBO scripts]# service mysqld start
Starting MySQL..The server quit without updating PID file (/var/lib/mysql/HKBO.pid).[FAILED]

#查看錯誤記錄檔
[root@HKBO scripts]# tail /var/log/mysqld.log
InnoDB: Apply batch completed
2014-12-08 11:01:37 15721 [Note] InnoDB: 128 rollback segment(s) are active.
2014-12-08 11:01:37 15721 [Note] InnoDB: Waiting for purge to start
2014-12-08 11:01:37 15721 [Note] InnoDB: 5.6.12 started; log sequence number 1600607
2014-12-08 11:01:37 15721 [Note] Server hostname (bind-address): '*'; port: 3306
2014-12-08 11:01:37 15721 [Note] IPv6 is available.
2014-12-08 11:01:37 15721 [Note]   - '::' resolves to '::';
2014-12-08 11:01:37 15721 [Note] Server socket created on IP: '::'.
2014-12-08 11:01:37 15721 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
141208 11:01:37 mysqld_safe mysqld from pid file /var/lib/mysql/HKBO.pid ended

# Author : Leshami
# Blog   :  http://blog.csdn.net/leshami

 

2、解決辦法
#查看當前的my.cnf設定檔
[root@HKBO scripts]# more /etc/my.cnf |grep -v ^#
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
old_passwords=1

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

#由於編譯安裝時指定的路徑為/opt/data以及mysql_install_db時指定的datadir也為/opt/data,而my.cnf為預設的路徑
#因此修改datadir至正確路徑後,問題解決
[root@HKBO scripts]# vi /etc/my.cnf
[root@HKBO support-files]# more /etc/my.cnf |grep datadir
datadir=/opt/data

[root@HKBO support-files]# service mysqld start
Starting MySQL.[  OK  ]

 

3、更多參考
Linux 下MySQL源碼安裝完整版
MySQL 源碼scr.rpm安裝的一點注意事項
Linux 5 下安裝MySQL 5.6(RPM方式)
Linux 下卸載MySQL 5

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.