北京SEO

Linux系统下Mysql数据库安装配置整理

2019/10/10/17:45:03  阅读:2019  来源:谷歌SEO算法  标签: 友情链接作弊

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. #wgethttp://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.20.tar.gz
  2. #tarzxvfmysql-5.6.20.tar.gz
  3. #cdmysql-5.6.20

2、安装cmake(mysql5.5以后源码安装都得通过cmake编译,并安装了ncurses ncurses-devel.

  1. #yum-yinstallcmakencursesncurses-devel
  2. #groupaddmysql
  3. #useradd-gmysqlmysql

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. #make&&makeinstall

参数说明:

  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. #chown-Rmysql:mysqldata/
  3. #cpsupport-files/my-default.cnfmy.cnf
  4. #vimy.cnf

编辑my.cnf:

  1. [mysqld]
  2. innodb_buffer_pool_size=100M
  3. basedir=/usr/local/webserver/mysql
  4. datadir=/usr/local/webserver/mysql/data
  5. port=3306
  6. server_id=1
  7. socket=/tmp/mysql.sock
  8. join_buffer_size=10M
  9. sort_buffer_size=10M
  10. read_rnd_buffer_size=12M
  11. query_cache_size=32M
  12. tmp_table_size=32M
  13. key_buffer_size=32M
  14. performance_schema_max_table_instances=1000
  15. table_definition_cache=800
  16. table_open_cache=512
  17. long_query_time=1
  18. slow_query_log=1
  19. slow_query_log_file=/usr/loca/webserver/mysql/data/slow-queries.log//phpfensi.com
  20. 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. StartingMySQL.ERROR!TheserverquitwithoutupdatingPIDfile(/usr/local/webserver/mysql/data/AY121218115148c506503.pid).
  2. 2014-08-1411:29:381678[Note]InnoDB:Usingmutexestorefcountbufferpoolpages
  3. 2014-08-1411:29:381678[Note]InnoDB:TheInnoDBmemoryheapisdisabled
  4. 2014-08-1411:29:381678[Note]InnoDB:Mutexesandrw_locksuseInnoDB'sownimplementation
  5. 2014-08-1411:29:381678[Note]InnoDB:Memorybarrierisnotused
  6. 2014-08-1411:29:381678[Note]InnoDB:Compressedtablesusezlib1.2.3
  7. 2014-08-1411:29:381678[Note]InnoDB:NotusingCPUcrc32instructions
  8. 2014-08-1411:29:381678[Note]InnoDB:Initializingbufferpool,size=100.0M
  9. InnoDB:mmap(106840064bytes)failed;errno12
  10. 2014-08-1411:29:381678[ERROR]InnoDB:Cannotallocatememoryforthebufferpool
  11. 2014-08-1411:29:381678[ERROR]Plugin'InnoDB'initfunctionreturnederror.
  12. 2014-08-1411:29:381678[ERROR]Plugin'InnoDB'registrationasaSTORAGEENGINEfailed.
  13. 2014-08-1411:29:381678[ERROR]Unknown/unsupportedstorageengine:InnoDB
  14. 2014-08-1411:29:381678[ERROR]Aborting

无法给innodb_buffer_pool_size分配100M内存,但启动Mysql之前实际上是有内存的,Mysql5.6有几个默认值,按照这些值启动需要消耗几百兆内存,然后再分配给innodb_buffer_pool_size就不足了,服务器上可怜的512M内存.

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

调整一下:

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

就只使用40---60M左右的内存了,重新启动mysql.

  1. #./support-files/mysql.serverstart
  2. StartingMySQL.SUCCESS!
  3. #cp./support-files/mysql.server/etc/rc.d/init.d/mysqld
  4. #chmod755/etc/init.d/mysqld
  5. #chkconfigmysqldon

广告内容

Linux系统下Mysql数据库安装配置整理 Linux系统下Mysql数据库安装配置整理 Linux系统下Mysql数据库安装配置整理

相关阅读

热门评论

小明SEO博客 小明SEO博客

小明SEO博客,新时代SEO博客

总篇数171

精选文章

RMAN中catalog和nocatalog区别介绍 小技巧:为Linux下的文件分配多个权限 zimbra8.5.1安装第三方签名ssl证书的步骤 解决mysql不能远程连接数据库方法 windows服务器mysql增量备份批处理数据库 mysql中slow query log慢日志查询分析 JavaScript跨域问题总结 Linux下负载均衡软件LVS配置(VS/DR)教程 mysql中权限参数说明 MYSQL(错误1053)无法正常启动

SEO最新算法