Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
关闭或重新启动计算机后,mysql表丢失或损坏_Mysql_Database_Osx Lion_Database Connection - Fatal编程技术网

关闭或重新启动计算机后,mysql表丢失或损坏

关闭或重新启动计算机后,mysql表丢失或损坏,mysql,database,osx-lion,database-connection,Mysql,Database,Osx Lion,Database Connection,我正在使用一个mysql本地数据库来存储我创建的两个ruby脚本中的一些数据。问题是,每当我重新启动或关闭计算机时,我的数据库似乎会损坏,因为当我尝试访问它时,它会显示以下错误: 无法连接到“Andres-MacBook-Air-3.local”(61)上的MySQL服务器(Mysql2::Error) 然后,我使用以下命令(在谷歌搜索时发现)恢复连接: cd /usr/local/mysql sudo ./bin/mysqld_safe (Enter your password, if nec

我正在使用一个mysql本地数据库来存储我创建的两个ruby脚本中的一些数据。问题是,每当我重新启动或关闭计算机时,我的数据库似乎会损坏,因为当我尝试访问它时,它会显示以下错误:
无法连接到“Andres-MacBook-Air-3.local”(61)上的MySQL服务器(Mysql2::Error)

然后,我使用以下命令(在谷歌搜索时发现)恢复连接:

cd /usr/local/mysql
sudo ./bin/mysqld_safe
(Enter your password, if necessary)
(Press Control-Z)
bg
执行此操作后,我可以连接到数据库,但当我尝试访问表时,出现以下错误:

Error retrieving table information
An error occurred while retrieving the information for table 'fourCheckins'. Please try again.

MySQL said: Table 'trackpuntos.fourcheckins' doesn't exist
我认为关闭/重新启动计算机是导致问题的原因,因为同样的情况发生了两次。幸运的是,在我第一次做mysqldump之后

有人知道为什么会发生这种情况/如何预防吗

我正在运行mysql 5.6.12,在运行OS Lion的macbook air上运行


谢谢

过去一周我一直有同样的问题。当我打开数据库连接并关闭/重新启动计算机时,我发现InnoDB数据库已损坏

我无意中通过Mac上的自制升级安装了mysql 5.6。我只是按照下面的说明将mysql回滚到5.5.29。降级到5.5后,我再次设置数据库,打开一组连接,然后关闭计算机。重新启动后,我没有腐败。希望它能保持这种状态

注意:对于您的系统,路径可能不同

  • 通过自制卸载5.6 mysql

    $ brew uninstall mysql
    $ rm -rf /usr/local/var/mysql
    
    $ cd /usr/local/Library/Formula
    $ git checkout -b mysql-5.5.29 336c97637c5449018cde59f7d2a87a298692da08
    $ brew install mysql
    
  • 通过自制安装5.5.29 mysql

    $ brew uninstall mysql
    $ rm -rf /usr/local/var/mysql
    
    $ cd /usr/local/Library/Formula
    $ git checkout -b mysql-5.5.29 336c97637c5449018cde59f7d2a87a298692da08
    $ brew install mysql
    
  • 请遵循mysql的所有安装后步骤

    $ unset TMPDIR
    $ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
    $ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
    $ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
    
  • 将自制重置为master!重要

    $ git checkout master 
    

  • 最后,在5.6变得更稳定之前不要升级mysql

    重新启动后,我也遇到了同样的问题。。。刚刚停止并重新启动了MySQL,之后我的数据库工作正常。

    谢谢@Uysrc!每当我必须关闭/重新启动我的计算机时,我会尝试一下,因为我现在正在停止我的mysql服务器。这个周末,我将把我的数据库移动到一个服务器上,以避免出现这种情况,然后将尝试您的解决方案。再次感谢。