我刚刚使用 Time Machine 恢复了我的硬盘。但是我无法连接到 MySQL。
当我输入时出现以下错误mysql -u root -p
。
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
当我输入时,我得到以下内容mysqld
。
感谢您的意见。提前致谢。
2014-04-02 11:27:56 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.
Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-04-02 11:27:56 10635 [Warning] Can't create test file /usr/local/mysql-5.6.10-osx10.7-x86_64/data/sokada-macbook.lower-test
2014-04-02 11:27:56 10635 [Warning] Can't create test file /usr/local/mysql-5.6.10-osx10.7-x86_64/data/sokada-macbook.lower-test
2014-04-02 11:27:56 10635 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Can't find file: './mysql/plugin.frm' (errno: 13 - Permission denied)
2014-04-02 11:27:56 10635 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2014-04-02 11:27:56 10635 [Note] InnoDB: The InnoDB memory heap is disabled
2014-04-02 11:27:56 10635 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-04-02 11:27:56 10635 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-04-02 11:27:56 10635 [Note] InnoDB: CPU does not support crc32 instructions
2014-04-02 11:27:56 10635 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-04-02 11:27:56 10635 [Note] InnoDB: Completed initialization of buffer pool
2014-04-02 11:27:56 10635 [ERROR] InnoDB: read can't be opened in ./ibdata1 mode
2014-04-02 11:27:56 10635 [ERROR] InnoDB: The system tablespace must be writable!
2014-04-02 11:27:56 10635 [ERROR] Plugin 'InnoDB' init function returned error.
2014-04-02 11:27:56 10635 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2014-04-02 11:27:56 10635 [ERROR] Unknown/unsupported storage engine: InnoDB
2014-04-02 11:27:56 10635 [ERROR] Aborting
2014-04-02 11:27:56 10635 [Note] Binlog end
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'partition'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_FT_INSERTED'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_METRICS'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_CMPMEM'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_CMP'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_LOCKS'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'INNODB_TRX'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'BLACKHOLE'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'ARCHIVE'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'MRG_MYISAM'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'MyISAM'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'MEMORY'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'CSV'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'sha256_password'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'mysql_old_password'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'mysql_native_password'
2014-04-02 11:27:56 10635 [Note] Shutting down plugin 'binlog'
2014-04-02 11:27:56 10635 [Note] mysqld: Shutdown complete
答案1
我按照此操作卸载 mysql并使用以下命令进行安装。
bash <(curl -Ls http://git.io/eUx7rg)
答案2
从 Time Machine 备份恢复后,我遇到了完全相同的问题。我必须完全重新安装 MySQL 才能修复它,因为我的/usr/local/mysql/data/mysql
目录已损坏。我遵循了以下步骤:
- 已移出
com.mysql.mysql.plist
/Library/LaunchDaemons - 将旧的 mysql 安装从 /usr/local 移至 /tmp
下载最新版本的 MySQL 源并安装:
$ cd /usr/local/src $ sudo wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.24.tar.gz $ sudo tar -xzvf mysql-5.6.24.tar.gz $ sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6.23 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DENABLED_LOCAL_INFILE=1 . $ sudo make $ sudo install $ sudo ln -s /usr/local/mysql-5.6.24 /usr/local/mysql $ cd /usr/local/mysql $ sudo chown -R root . $ sudo chgrp -R mysql . $ sudo chown -R mysql data $ sudo scripts/mysql_install_db --user=mysql
更新/usr/local/mysql/my.cnf
:
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
character-set-server=utf8
collation-server=utf8_general_ci
character-set-client-handshake=false
按照安装后说明运行mysql_install_db
命令。
此时,我尝试将旧数据目录复制到新设置中,但由于旧数据目录不是 ibdata1 的一部分,因此我收到错误消息,提示旧数据库的表不存在。有一些解决方案可以修复 ibdata1 文件,例如http://www.ipserverone.info/database/how-to-recover-an-orphan-innodb-database-from-ibd-file/,但它们涉及对每个表的操作,这对我来说太耗时了。我能够重新创建数据库并从以前的转储中导入数据。