mysql-python:无法打开和锁定权限表:表'mysql.host'不存在

时间:2012-04-15 02:14:46

标签: mysql-python python-db-api

我使用自制软件安装了mysql。

我现在正在尝试安装mysql-python,当我运行mysql时,我不断收到以下错误。

我是编程的新手,并且不太了解问题。

任何帮助将不胜感激。谢谢。

 TDNS-Mac-mini:~ TDNS$ easy_install mysql-python
    /Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install:5: UserWarning: Module pkg_resources was already imported from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.pyc, but /Library/Python/2.7/site-packages/distribute-0.6.24-py2.7.egg is being added to sys.path
      from pkg_resources import load_entry_point
    /Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install:5: UserWarning: Module site was already imported from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.pyc, but /Library/Python/2.7/site-packages/distribute-0.6.24-py2.7.egg is being added to sys.path
      from pkg_resources import load_entry_point
    Searching for mysql-python
    Reading http://pypi.python.org/simple/mysql-python/
    Reading http://sourceforge.net/projects/mysql-python/
    Reading http://sourceforge.net/projects/mysql-python
    Best match: MySQL-python 1.2.3
    Downloading http://download.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3.tar.gz
    Processing MySQL-python-1.2.3.tar.gz
    Running MySQL-python-1.2.3/setup.py -q bdist_egg --dist-dir /var/folders/c9/xzv35t2n3ld9lgjrtl0vd0xr0000gn/T/easy_install-LsUpDW/MySQL-python-1.2.3/egg-dist-tmp-vzGMr9
    warning: no files found matching 'MANIFEST'
    warning: no files found matching 'ChangeLog'
    warning: no files found matching 'GPL'
    unable to execute gcc-4.2: No such file or directory
    error: Setup script exited with error: command 'gcc-4.2' failed with exit status 1

TDNS-Mac-mini:~ TDNS$ mysqld
        120414 22:02:41 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
        mysqld: Table 'mysql.plugin' doesn't exist
        120414 22:02:41 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
        120414 22:02:41 InnoDB: The InnoDB memory heap is disabled
        120414 22:02:41 InnoDB: Mutexes and rw_locks use GCC atomic builtins
        120414 22:02:41 InnoDB: Compressed tables use zlib 1.2.5
        120414 22:02:41 InnoDB: Initializing buffer pool, size = 128.0M
        120414 22:02:41 InnoDB: Completed initialization of buffer pool
        120414 22:02:41 InnoDB: highest supported file format is Barracuda.
        InnoDB: The log sequence number in ibdata files does not match
        InnoDB: the log sequence number in the ib_logfiles!
        120414 22:02:41  InnoDB: Database was not shut down normally!
        InnoDB: Starting crash recovery.
        InnoDB: Reading tablespace information from the .ibd files...
        InnoDB: Restoring possible half-written data pages from the doublewrite
        InnoDB: buffer...
        120414 22:02:41  InnoDB: Waiting for the background threads to start
        120414 22:02:42 InnoDB: 1.1.8 started; log sequence number 1595675
        120414 22:02:42 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

1 个答案:

答案 0 :(得分:12)

我明白了。我忘记按照终端中自制安装说明顶部的说明进行操作。

希望为犯同样错误的人节省时间。

Set up databases to run AS YOUR USER ACCOUNT with:
    unset TMPDIR
    mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

To set up base tables in another folder, or use a different user to run
mysqld, view the help for mysqld_install_db:
    mysql_install_db --help

and view the MySQL documentation:
  * http://dev.mysql.com/doc/refman/5.5/en/mysql-install-db.html
  * http://dev.mysql.com/doc/refman/5.5/en/default-privileges.html

To run as, for instance, user "mysql", you may need to `sudo`:
    sudo mysql_install_db ...options...

Start mysqld manually with:
    mysql.server start

    Note: if this fails, you probably forgot to run the first two steps up above