月度归档: 2017 年 7 月

  • XAMPP on Mac 配置 Virual Host虚拟主机 图文教程

    XAMPP on Mac 配置 Virual Host虚拟主机 图文教程

    最近新购买了MacBook,下面记录一下 XAMPP on Mac 配置 Virual Host全过程。

    修改本机hosts

    先在hosts文件里加入virtual host的域名,指向127.0.0.1 我一般使用的命名规则是 laoji ,在终端运行 sudo vi /private/etc/hosts

    添加域名解析到本机

    # VirtualHosts Mapping   
    127.0.0.1 laoji

    修改Apache中的配置文件

    接下来配置Apache,打开Apache的配置文件 /Applications/XAMPP/etc/httpd.conf

    搜索 “Virtual hosts” # Virtual hosts # Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf

    把第二行注释打开,让Apache去读虚拟主机的配置文件 # Virtual hosts Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf

    在以上httpd-vhosts.conf里添加Virtual Host的配置 # localhost  

    <VirtualHost *:80>       
        ServerName localhost       
        DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"       
        <Directory "/Applications/XAMPP/xamppfiles/htdocs">           
            Options Indexes FollowSymLinks Includes execCGI           
            AllowOverride All           
            Require all granted     
        </Directory> 
    </VirtualHost> 
    # My custom host 
    <VirtualHost *:80>     
        ServerName laoji     
        DocumentRoot "/Users/yourusername/path/to/your/site"       
        <Directory "/Users/yourusername/path/to/your/site">           
            Options Indexes FollowSymLinks Includes ExecCGI           
            AllowOverride All           
            Require all granted     
        </Directory>
        #ErrorLog "logs/mysite.local-error_log" 
    </VirtualHost> 

    重启Apache,访问http://laoji 出现403错误,在httpd.conf里面搜索User Deamon,把deamon改成OS的用户名,重启Apache。   如果依然显示403,编辑  /Applications/XAMPP/xamppfiles/etc/httpd.conf

    vi /Applications/XAMPP/xamppfiles/etc/httpd.conf

    找到:

    <Directory />     
        AllowOverride none     
        Require all denied 
    </Directory>

    将以上内容修改为:

    <Directory />     
        AllowOverride All     
        Require all granted     
        #AllowOverride none     
        #Require all denied 
    </Directory>

    重启Apache即可。

  • InnoDB: Error: Table “mysql”.”innodb_table_stats” not found.

    InnoDB: Error: Table “mysql”.”innodb_table_stats” not found.

    1,Mysqldump的时候报错如下:

    2014-05-05?14:12:37?7f004a9a2700?InnoDB:?Error:?Table?”MySQL”.”innodb_table_stats”?not?found.

    但是show tables我看这个表示存在的:

    但是show create table innodb_index_stats;报错如下:

    1. mysql>??show?create?table?innodb_index_stats;
    2. ERROR?1146?(42S02):?Table‘mysql.innodb_index_stats’?doesn’t?exist
    3. mysql>

     

    2,估计是表坏了,去数据库服务器上面的mysql库的目录看下这些表的数据文件:

     

     

    3,看到表的数据文件以及结构文件都存在

    然后去找$MYSQL_HOME/share/mysql_system_tables.sql,search到建表语句

     

    打开mysql_system_tables.sql,找到sql,然后执行:

    1. mysql>?CREATETABLE?IF?NOT?EXISTS?innodb_index_stats?(
    2. ????->?????????database_name???????????????????VARCHAR(64)?NOT?NULL,
    3. ????->?????????table_name??????????????????????VARCHAR(64)?NOT?NULL,
    4. ????->?????????index_name??????????????????????VARCHAR(64)?NOT?NULL,
    5. ????->?????????last_update?????????????????????TIMESTAMP?NOT?NULL?NOTNULL?DEFAULT?CURRENT_TIMESTAMP?ON?UPDATE?CURRENT_TIMESTAMP,
    6. ????->?????????stat_name???????????????????????VARCHAR(64)?NOT?NULL,
    7. ????->?????????stat_value??????????????????????BIGINT?UNSIGNED?NOT?NULL,
    8. ????->?????????sample_size?????????????????????BIGINT?UNSIGNED,
    9. ????->?????????stat_description????????????????VARCHAR(1024)?NOT?NULL,
    10. ????->?????????PRIMARY?KEY?(database_name,table_name,?index_name,?stat_name)
    11. ????->?)?ENGINE=INNODB?DEFAULT?CHARSET=utf8COLLATE=utf8_bin?STATS_PERSISTENT=0;
    12. ERROR?1146(42S02):?Table?‘mysql.innodb_index_stats’?doesn’t?exist
    13. mysql>
    14. mysql>

     

    还报错Table ‘mysql.innodb_index_stats’ doesn’texist,可能是那个判断导致,去掉判断试试:

    1. mysql>?CREATETABLE?innodb_index_stats?(
    2. ????->????????database_name???????????????????VARCHAR(64)?NOT?NULL,
    3. ????->?????????table_name??????????????????????VARCHAR(64)?NOT?NULL,
    4. ????->?????????index_name??????????????????????VARCHAR(64)?NOT?NULL,
    5. ????->?????????last_update?????????????????????TIMESTAMP?NOT?NULL?NOTNULL?DEFAULT?CURRENT_TIMESTAMP?ON?UPDATE?CURRENT_TIMESTAMP,
    6. ????->?????????stat_name???????????????????????VARCHAR(64)?NOT?NULL,
    7. ????->?????????stat_value??????????????????????BIGINT?UNSIGNED?NOT?NULL,
    8. ????->?????????sample_size?????????????????????BIGINT?UNSIGNED,
    9. ????->?????????stat_description????????????????VARCHAR(1024)?NOT?NULL,
    10. ????->?????????PRIMARY?KEY?(database_name,table_name,?index_name,?stat_name)
    11. ????->?)?ENGINE=INNODB?DEFAULT?CHARSET=utf8COLLATE=utf8_bin?STATS_PERSISTENT=0;
    12. ERROR?1146(42S02):?Table?’mysql.innodb_index_stats’?doesn’t?exist

     

    诡异,不存在还不让create了,是否原来的数据文件存在不过坏了,所以create的时候就报了这样一个诡异的错误呢?

     

    4,去数据库目录看下,果然文件是否已经存在了:

    1. [root@xxx?mysql]#?ll?/home/data/mysql/data/mysql/innodb*
    2. -rw-rw—-.?1mysql?mysql??12982?4月???922:24?/home/data/mysql/data/mysql/innodb_index_stats.frm
    3. -rw-rw—-.?1mysql?mysql?180224?5月???6?10:38/home/data/mysql/data/mysql/innodb_index_stats.ibd
    4. -rw-rw—-.?1mysql?mysql???8830?4月???922:24?/home/data/mysql/data/mysql/innodb_table_stats.frm
    5. -rw-rw—-.?1mysql?mysql??98304?5月???610:38?/home/data/mysql/data/mysql/innodb_table_stats.ibd
    6. [root@xxx?mysql]#

    如果是myisam表还可以用命令修复一下,但是innnodb,就只好重启数据库试试,restart之后,进入mysql库:

    1. mysql>?descinnodb_index_stats;
    2. ERROR?1146(42S02):?Table?‘mysql.innodb_index_stats’?doesn’t?exist

    还是报错,那就只有drop操作:

    1. mysql>?droptable?mysql.innodb_index_stats;
    2. ERROR?1051(42S02):?Unknown?table?‘mysql.innodb_index_stats’
    3. mysql>
    4. mysql>

     

    5,RM操作删除掉旧的坏的数据表文件

    drop还是报错,最后看来只有一招了,rm -rf掉原来已经存在坏掉的不能加载的innodb_index_stats文件,再重新create了。

    1. rm?-rf/home/data/mysql/data/mysql/innodb*

    rm后再登陆mysql执行create操作。

    1. mysql>?usemysql;
    2. Database?changed
    3. mysql>
    4. mysql>??CREATE?TABLE?innodb_index_stats?(
    5. ????->?????????????database_name???????????????????VARCHAR(64)?NOT?NULL,
    6. ????->?????????????table_name??????????????????????VARCHAR(64)?NOT?NULL,
    7. ????->?????????????index_name??????????????????????VARCHAR(64)?NOT?NULL,
    8. ????->?????????????last_update?????????????????????TIMESTAMP?NOT?NULL?NOTNULL?DEFAULT?CURRENT_TIMESTAMP?ON?UPDATE?CURRENT_TIMESTAMP,
    9. ????->?????????????stat_name???????????????????????VARCHAR(64)?NOT?NULL,
    10. ????->?????????????stat_value??????????????????????BIGINT?UNSIGNED?NOT?NULL,
    11. ????->?????????????sample_size?????????????????????BIGINT?UNSIGNED,
    12. ????->?????????????stat_description????????????????VARCHAR(1024)?NOT?NULL,
    13. ????->?????????????PRIMARY?KEY?(database_name,table_name,?index_name,?stat_name)
    14. ????->????)?ENGINE=INNODB?DEFAULT?CHARSET=utf8?COLLATE=utf8_binSTATS_PERSISTENT=0;
    15. Query?OK,?0?rowsaffected?(0.02?sec)

     

    创建innodb_index_stats成功了。最后执行原来的mysqldump备份操作,一切正常。

  • 修复mysql:[ERROR] Native table ‘performance_schema’

    修复mysql:[ERROR] Native table ‘performance_schema’

    mysql数据库出现如下错误,主要是因为升级了mysql软件包,而一些数据库的表结构发生变化而无法正常运行。

    140213 16:55:47 [ERROR] Native table ‘performance_schema’.’events_waits_current’ has the wrong structure
    140213 16:55:47 [ERROR] Native table ‘performance_schema’.’events_waits_history’ has the wrong structure
    140213 16:55:47 [ERROR] Native table ‘performance_schema’.’events_waits_history_long’ has the wrong structure
    140213 16:55:47 [ERROR] Native table ‘performance_schema’.’setup_consumers’ has the wrong structure
    140213 16:55:47 [ERROR] Native table ‘performance_schema’.’setup_instruments’ has the wrong structure
    140213 16:55:47 [ERROR] Native table ‘performance_schema’.’setup_timers’ has the wrong structure
    140213 16:55:47 [ERROR] Native table ‘performance_schema’.’performance_timers’ has the wrong structure
    140213 16:55:47 [ERROR] Native table ‘performance_schema’.’threads’ has the wrong structure
    140213 16:55:47 [ERROR] Native table ‘performance_schema’.’events_waits_summary_by_thread_by_event_name’ has the wrong structure
    140213 16:55:47 [ERROR] Native table ‘performance_schema’.’events_waits_summary_by_instance’ has the wrong structure
    140213 16:55:47 [ERROR] Native table ‘performance_schema’.’events_waits_summary_global_by_event_name’ has the wrong structure
    140213 16:55:47 [ERROR] Native table ‘performance_schema’.’file_summary_by_event_name’ has the wrong structure
    140213 16:55:47 [ERROR] Native table ‘performance_schema’.’file_summary_by_instance’ has the wrong structure
    140213 16:55:47 [ERROR] Native table ‘performance_schema’.’mutex_instances’ has the wrong structure
    140213 16:55:47 [ERROR] Native table ‘performance_schema’.’rwlock_instances’ has the wrong structure
    140213 16:55:47 [ERROR] Native table ‘performance_schema’.’cond_instances’ has the wrong structure
    140213 16:55:47 [ERROR] Native table ‘performance_schema’.’file_instances’ has the wrong structure

    修复方法很简单只需在root权限下运行如下命令即可:

    /usr/local/mysql/bin/mysql_upgrade -u root -p

    输入命令后会要求验证mysql密码,填入密码后确认如下图所示即表示修复完毕:

    mysql_upgrade

  • OSX上安装MAME模拟器 开始游戏黑屏 有声音

    OSX上安装MAME模拟器 开始游戏黑屏 有声音

    我试用的是最新的 0.135版

    下载地址:MAME OS X

    我的操作系统是 OSX EI Capitan 10.11.3 BETA,在运行游戏时出现黑屏的问题,经过查资料,解决方法如下:

    打开Preferences,选择Video,Rendering Options -> Render frames using:选择[OpenGL]?设置

    显示游戏界面后,要先设置游戏手柄的设置,点击游戏屏幕,点击:Tab键,进入设置界面,根据菜单设置即可!

WeChat
↑