国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

Linux系統下Mysql數據庫安裝配置整理

2024-08-27 23:59:45
字體:
來源:轉載
供稿:網友

Mysql安裝對于各位站長來講是非常重要的一個網如果沒有數據庫那必須不是什么好站了,好站都會有Mysql數據庫了,下面我們就來介紹Mysql安裝配置教程.

Mysql安裝

1、通過官網下載mysql源碼包,http://dev.mysql.com/downloads/ 點擊MySQL Community Server,選擇Source Code,點擊 Generic Linux.

(Architecture Independent),Compressed TAR Archive后的Download.

  1. # wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.20.tar.gz 
  2. # tar zxvf mysql-5.6.20.tar.gz  
  3. # cd mysql-5.6.20 

2、安裝cmake(mysql5.5以后源碼安裝都得通過cmake編譯,并安裝了ncurses ncurses-devel.

  1. # yum -y install cmake ncurses ncurses-devel 
  2.  
  3. # groupadd mysql 
  4.  
  5. # useradd -g mysql mysql 

3、編譯并安裝

  1. # cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql -DMYSQL_DATADIR=/usr/local/webserver/mysql -DSYSCONFDIR=/usr/local/webserver/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci  -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1 
  2.  
  3. # make && make install 

參數說明:

  1. -DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql //指定安裝目錄 
  2. -DINSTALL_DATADIR=/usr/local/webserver/mysql //指定數據存放目錄 
  3. -DSYSCONFDIR=/usr/local/webserver/mysql //指定配置文件目錄(本例的配置文件為/opt/mysql/my.cnf) 
  4. -DDEFAULT_CHARSET=utf8 //指定字符集 
  5. -DDEFAULT_COLLATION=utf8_general_ci //指定校驗字符 
  6. -DEXTRA_CHARSETS=all //安裝所有擴展字符集 
  7. -DENABLED_LOCAL_INFILE=1 //允許從本地導入數據 

編譯出錯需刪掉CMakeCache.txt

# rm CMakeCache.txt

拷貝mysql配置文件,并進行相應配置,這里是服務器是阿里云的最低配置,單核 512M內存.

  1. # cd /usr/local/webserver/mysql 
  2.  
  3. # chown -R mysql:mysql data/ 
  4.  
  5. # cp support-files/my-default.cnf  my.cnf 
  6.  
  7. # vi my.cnf 

編輯my.cnf:

  1. [mysqld] 
  2.  
  3. innodb_buffer_pool_size = 100M 
  4.  
  5. basedir = /usr/local/webserver/mysql 
  6.  
  7. datadir = /usr/local/webserver/mysql/data 
  8.  
  9. port = 3306 
  10.  
  11. server_id = 1 
  12.  
  13. socket = /tmp/mysql.sock 
  14.  
  15. join_buffer_size = 10M 
  16.  
  17. sort_buffer_size = 10M 
  18.  
  19. read_rnd_buffer_size = 12M  
  20.  
  21. query_cache_size = 32M 
  22.  
  23. tmp_table_size = 32M 
  24.  
  25. key_buffer_size = 32M 
  26.  
  27. performance_schema_max_table_instances=1000 
  28.  
  29. table_definition_cache=800 
  30.  
  31. table_open_cache=512 
  32.  
  33. long_query_time=1 
  34.  
  35. slow_query_log=1 
  36.  
  37. slow_query_log_file=/usr/loca/webserver/mysql/data/slow-queries.log  //Vevb.com 
  38.  
  39. log_queries_not_using_indexes=1 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

初始化Mysql數據庫:

/usr/loca/webserver/mysql/scripts/mysql_install_db --user=mysql

啟動Mysql:

# ./support-files/mysql.server start

報錯:

  1. Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/webserver/mysql/data/AY121218115148c506503.pid). 
  2.  
  3. 2014-08-14 11:29:38 1678 [Note] InnoDB: Using mutexes to ref count buffer pool pages 
  4. 2014-08-14 11:29:38 1678 [Note] InnoDB: The InnoDB memory heap is disabled 
  5. 2014-08-14 11:29:38 1678 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation 
  6. 2014-08-14 11:29:38 1678 [Note] InnoDB: Memory barrier is not used 
  7. 2014-08-14 11:29:38 1678 [Note] InnoDB: Compressed tables use zlib 1.2.3 
  8. 2014-08-14 11:29:38 1678 [Note] InnoDB: Not using CPU crc32 instructions 
  9. 2014-08-14 11:29:38 1678 [Note] InnoDB: Initializing buffer pool, size = 100.0M 
  10. InnoDB: mmap(106840064 bytes) failed; errno 12 
  11. 2014-08-14 11:29:38 1678 [ERROR] InnoDB: Cannot allocate memory for the buffer pool 
  12. 2014-08-14 11:29:38 1678 [ERROR] Plugin 'InnoDB' init function returned error. 
  13. 2014-08-14 11:29:38 1678 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 
  14. 2014-08-14 11:29:38 1678 [ERROR] Unknown/unsupported storage engine: InnoDB 
  15. 2014-08-14 11:29:38 1678 [ERROR] Aborting 

無法給innodb_buffer_pool_size分配100M內存,但啟動Mysql之前實際上是有內存的,Mysql5.6有幾個默認值,按照這些值啟動需要消耗幾百兆內存,然后再分配給innodb_buffer_pool_size就不足了,服務器上可憐的512M內存.

  1. performance_schema_max_table_instances = 12500 
  2.  
  3. table_definition_cache = 1400 
  4.  
  5. table_open_cache = 2000 

調整一下:

  1. performance_schema_max_table_instances=600 
  2.  
  3. table_definition_cache=400 
  4.  
  5. table_open_cache=256 

就只使用40---60M左右的內存了,重新啟動mysql.

  1. # ./support-files/mysql.server start 
  2.  
  3. Starting MySQL. SUCCESS! 
  4.  
  5. # cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld 
  6.  
  7. # chmod 755 /etc/init.d/mysqld  
  8.  
  9. # chkconfig mysqld on

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 蒙阴县| 巴马| 崇仁县| 循化| 桦南县| 加查县| 开平市| 休宁县| 驻马店市| 什邡市| 青铜峡市| 津市市| 锦屏县| 海盐县| 安仁县| 元谋县| 锦州市| 溆浦县| 涟源市| 邯郸市| 娄烦县| 西乌| 咸宁市| 呼伦贝尔市| 清苑县| 贺州市| 泾源县| 林州市| 榕江县| 绥江县| 曲周县| 辽宁省| 嫩江县| 香港 | 纳雍县| 衡阳市| 湖北省| 山西省| 松滋市| 嘉义市| 利川市|