1. 程式人生 > >Linux 下沒有 my.cnf 檔案的解決方式,完全是我自己整的,好多教程都是瞎扯的

Linux 下沒有 my.cnf 檔案的解決方式,完全是我自己整的,好多教程都是瞎扯的

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, else10%.  
  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. # Remove leading   
  33. # to turn on a very important data integrity option: logging  
  34. # changes to the binary log between backups.  
  35. #lob_bin  
  36. log_bin=ON  
  37. log_bin_basename=/var/lib/mysql/mysqld-bin  
  38. #  
  39. # Remove leading # to set options mainly useful for reporting servers.  
  40. # The server defaults are faster for transactions and fast SELECTs.  
  41. # Adjust sizes as needed, experiment to find the optimal values.  
  42. join_buffer_size = 128M  
  43. sort_buffer_size = 2M  
  44. read_rnd_buffer_size = 2M  
  45. datadir=/var/lib/mysql  
  46. socket=/var/lib/mysql/mysql.sock  
  47. character_set_server=utf8  
  48. #init_connect='SET NAMES utf8'
  49. # Disabling symbolic-links is recommended to prevent assorted security risks  
  50. symbolic-links=0
  51. # Recommended in standard MySQL setup  
  52. sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES  
  53. #general_log  
  54. general_log=ON  
  55. general_log_file=/var/lib/mysql/localhost.log  
  56. #slow_query_log  
  57. slow_query_log=ON  
  58. slow_query_log_file=/var/lib/mysql/localhost-slow.log  
  59. slow_launch_time=2
  60. [mysqld_safe]  
  61. log-error=/var/log/mysqld.log  
  62. 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. [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. mysql> show variables like 'log_bin';  
  19. +---------------+-------+  
  20. | Variable_name | Value |  
  21. +---------------+-------+  
  22. | log_bin       | OFF   |  
  23. +---------------+-------+  
  24. 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)  


需要開啟的可以自己設定,希望可以幫到大家,少走歪路!