zoukankan      html  css  js  c++  java
  • Linux 下没有 my.cnf 文件的解决方式,完全是我自己整的,好多教程都是瞎扯的 (zhuan)

    http://blog.csdn.net/jspping/article/details/40400691?utm_source=tuicool&utm_medium=referral

    ******************************************************************************

    我看过好多关于Linux下没有my.cnf的博客,都是什么rmp安装没有my.cnf文件啊,然后什么两个方法啊,我就无语了,大家要是知道就不会查资料了,你们敢不敢负责点?说详细点?有的说从 /usr/share/MySQL 里复制一个.cnf文件到 /etc 下,有用吗?配置文件资料不给别人,复制个毛线?复制谁都会!


    my.cnf 配置文件:


    1. # For advice on how to change settings please see  
    2. # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html  
    3. # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the  
    4. # *** default location during install, and will be replaced if you  
    5. # *** upgrade to a newer version of MySQL.  
    6. [mysqld]  
    7. #innodb  
    8. # Remove leading   
    9. # and set to the amount of RAM for the most important data  
    10. # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.  
    11. innodb_buffer_pool_size = 4000M  
    12. innodb_additional_mem_pool_size=60M  
    13. innodb_data_home_dir=  
    14. innodb_date_file_path=ibdata1:20M:autoextend  
    15. innodb_log_group_home_dir=/var/log/innodb_log  
    16. innodb_log_files_in_group=2  
    17. innodb_log_file_size=30M  
    18. innodb_log_buffer_size=3M  
    19. innodb_doublewrite=ON  
    20. innodb_open_file=2000  
    21. innodb_file_per_table=ON  
    22. innodb_max_dirty_page_pct=50  
    23. back_log=80  
    24. interactive_timeout=3600  
    25. key_buffer_size=10M  
    26. max_allow_packet=40440  
    27. max_connections=1000  
    28. max_tmp_tables=60  
    29. query_cache_size=10M  
    30. sor_buffer_size=10M  
    31. table_open_cache=2000  
    32.   
    33. # Remove leading   
    34. # to turn on a very important data integrity option: logging  
    35. # changes to the binary log between backups.  
    36. #lob_bin  
    37. log_bin=ON  
    38. log_bin_basename=/var/lib/mysql/mysqld-bin  
    39. #  
    40. # Remove leading # to set options mainly useful for reporting servers.  
    41. # The server defaults are faster for transactions and fast SELECTs.  
    42. # Adjust sizes as needed, experiment to find the optimal values.  
    43. join_buffer_size = 128M  
    44. sort_buffer_size = 2M  
    45. read_rnd_buffer_size = 2M  
    46. datadir=/var/lib/mysql  
    47. socket=/var/lib/mysql/mysql.sock  
    48. character_set_server=utf8  
    49. #init_connect='SET NAMES utf8'  
    50. # Disabling symbolic-links is recommended to prevent assorted security risks  
    51. symbolic-links=0  
    52.   
    53. # Recommended in standard MySQL setup  
    54. sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES  
    55. #general_log  
    56. general_log=ON  
    57. general_log_file=/var/lib/mysql/localhost.log  
    58. #slow_query_log  
    59. slow_query_log=ON  
    60. slow_query_log_file=/var/lib/mysql/localhost-slow.log  
    61. slow_launch_time=2  
    62.   
    63. [mysqld_safe]  
    64. log-error=/var/log/mysqld.log  
    65. pid-file=/var/run/mysqld/mysqld.pid  


    如果上述文件配置好后,执行mysql登录,抛出xxxx.line 这样的异常,就去/usr/share/mysql 下面复制一个.cnf文件的头部替换掉上述my.cnf的头部代码,前提是要copy一个到/etc下,命名my.cnf,再把上面的copy,版本信息和一些详细文件的

    具体路径配置,和参数配置看你自己的安装情况


    我替换的是/usr/share/mysql/my-default.cnf 头文件的这几句:

    1. # For advice on how to change settings please see  
    2. # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html  
    3. # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the  
    4. # *** default location during install, and will be replaced if you  
    5. # *** upgrade to a newer version of MySQL.  
    6.   
    7. [mysqld]  


    然后[mysqlld]以下的全部是copy上面的,从上面配置文件的第7行的#号开始,可以解决类似Fatal error in defaults handling. Program aborted 或者xxxx line xxxx 错误的问题,根据你服务器的具体情况具体分析,我的是以我配置的为基准的


    配置完之后,mysql可以正常登录,查看和启动日志:

    1. mysql> show variables like 'log_%';  
    2. +----------------------------------------+------------------------------------+  
    3. | Variable_name                          | Value                              |  
    4. +----------------------------------------+------------------------------------+  
    5. | log_bin                                | OFF                                |  
    6. | log_bin_basename                       |                                    |  
    7. | log_bin_index                          |                                    |  
    8. | log_bin_trust_function_creators        | OFF                                |  
    9. | log_bin_use_v1_row_events              | OFF                                |  
    10. | log_error                              | /var/lib/mysql/AY140615022008Z.err |  
    11. | log_output                             | FILE                               |  
    12. | log_queries_not_using_indexes          | OFF                                |  
    13. | log_slave_updates                      | OFF                                |  
    14. | log_throttle_queries_not_using_indexes | 0                                  |  
    15. | log_warnings                           | 1                                  |  
    16. +----------------------------------------+------------------------------------+  
    17. 11 rows in set (0.01 sec)  
    18.   
    19. mysql> show variables like 'log_bin';  
    20. +---------------+-------+  
    21. | Variable_name | Value |  
    22. +---------------+-------+  
    23. | log_bin       | OFF   |  
    24. +---------------+-------+  
    25. 1 row in set (0.00 sec)  


    1. mysql> select version();  
    2. +-----------+  
    3. | version() |  
    4. +-----------+  
    5. | 5.6.10    |  
    6. +-----------+  
    7. 1 row in set (0.02 sec)  



    需要开启的可以自己设置,希望可以帮到大家,少走歪路!

  • 相关阅读:
    JVisualVM简介与内存泄漏实战分析
    高并发性能提升和超卖的解决方案
    ehcache应用场景及集群同步(RMI)
    一台机器配置多个tomcat的实践经验
    事务范围数据库读写分离失败
    基于spring的数据库读写分离
    Zookeeper linux下使用
    Zookeeper集群
    Dubbo入门实例(二)
    Zookeeper安装与启动
  • 原文地址:https://www.cnblogs.com/zhao1949/p/6116923.html
Copyright © 2011-2022 走看看