北京SEO

linux中mysql 5.5二进制文件安装详解

2019/10/10/17:35:19  阅读:2035  来源:谷歌SEO算法  标签: 微服务

本文章来给大家介绍linux中mysql 5.5二进制文件安装方法,有需要了解的朋友根据下面方法即可实现安装mysql5了.

1、创建相关目录用户,代码如下:

  1. su–root
  2. groupaddmysql
  3. useradd-gmysql-pxifenfei-s/bin/bash-mmysql-d/opt/mysql
  4. MYSQL_BASE=/opt/mysql
  5. mkdir-p$MYSQL_BASE/product/5.5
  6. mkdir-p$MYSQL_BASE/mysqldata
  7. mkdir-p$MYSQL_BASE/mysqllog
  8. mkdir-p/var/run/mysqld/
  9. chmod-R777$MYSQL_BASE
  10. chown-Rmysql:mysql$MYSQL_BASE
  11. chown-Rmysql:mysql/var/run/mysqld

2、环境变量配置,代码如下:

  1. exportMYSQL_BASE=/opt/mysql
  2. exportbasedir=$MYSQL_BASE/product/5.5
  3. exportdatadir=$MYSQL_BASE/mysqldata
  4. exportLD_LIBRARY_PATH=$basedir/lib:/lib:/usr/lib:/usr/local/lib
  5. exportTMPDIR=/tmp
  6. exportPATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
  7. exportPATH=$basedir:$basedir/bin:${PATH}:$LD_LIBRARY_PATH

3、调整mysql 用户系统限制(可选)

编辑文件:/etc/security/limits.conf 加入以下语句:

  1. mysqlsoftnproc2047
  2. mysqlhardnproc16384
  3. mysqlsoftnofile1024
  4. mysqlhardnofile65536

确认如下语句是否存在于/etc/pam.d/login,如果不存在请增加:

session required pam_limits.so

如果用户SHELL 用的是Bourne,Bash,或者Korn shell 修改/etc/profile,并增加如下内容,在SuSe 操作系统上,则需要修改/etc/profile.local,代码如下:

  1. if[$USER="mysql"];then
  2. if[$SHELL="/bin/ksh"];then
  3. ulimit-p16384
  4. ulimit-n65536
  5. else
  6. ulimit-u16384-n65536
  7. fi
  8. fi

4、安装数据库

4.1)解压数据库至/opt/mysql/product/5.5中

4.2)安装数据,代码如下:

  1. [mysql@localhost~]$cdproduct/5.5/scripts/
  2. [mysql@localhostscripts]$./mysql_install_db–basedir=$basedir–datadir=$datadir–user=mysql

4.3)设置my.cnf参数,代码如下:

  1. vi/etc/my.cnf
  2. [mysqladmin]
  3. socket=/var/run/mysqld/mysqld.sock
  4. [client]
  5. port=3306
  6. socket=/var/run/mysqld/mysqld.sock
  7. [mysqld]
  8. port=3306
  9. socket=/var/run/mysqld/mysqld.sock
  10. user=mysql
  11. pid-file=/var/run/mysqld/mysqld.pid
  12. basedir=/opt/mysql/product/5.5
  13. datadir=/opt/mysql/mysqldata
  14. skip-external-locking=1
  15. interactive_timeout=1200
  16. wait_timeout=1200
  17. character-set-server=utf8
  18. back_log=500
  19. default_time_zone='+08:00'
  20. max_connections=1000
  21. max_connect_errors=1000
  22. connect_timeout=300
  23. table_open_cache=100
  24. max_allowed_packet=16M
  25. binlog_cache_size=8M
  26. max_heap_table_size=64M
  27. sort_buffer_size=8M
  28. join_buffer_size=8M
  29. thread_cache_size=32
  30. thread_concurrency=16
  31. query_cache_size=0M
  32. default-storage-engine=INNODB
  33. thread_stack=192K
  34. transaction_isolation=READ-COMMITTED
  35. tmp_table_size=64M
  36. log-bin=/opt/mysql/mysqllog/mysqlbin
  37. log-error=/opt/mysql/mysqllog/mysqld.err
  38. expire_logs_days=7
  39. binlog_format=ROW
  40. max_binlog_size=300M
  41. slow_query_log=1
  42. slow_query_log_file=/opt/mysql/mysqllog/mysqld-slow
  43. long_query_time=10
  44. tmpdir=/tmp
  45. server-id=1
  46. key_buffer_size=8M
  47. read_buffer_size=1M
  48. read_rnd_buffer_size=1M
  49. bulk_insert_buffer_size=1M
  50. myisam_sort_buffer_size=128K
  51. innodb_additional_mem_pool_size=16M
  52. innodb_buffer_pool_size=2G
  53. innodb_data_file_path=ibdata1:1024M:autoextend
  54. innodb_autoextend_increment=64
  55. innodb_file_per_table=1
  56. innodb_data_home_dir=/opt/mysql/mysqldata
  57. innodb_file_io_threads=4
  58. innodb_thread_concurrency=16
  59. innodb_flush_log_at_trx_commit=2
  60. innodb_log_buffer_size=8M
  61. innodb_log_file_size=512M
  62. innodb_log_files_in_group=3
  63. innodb_max_dirty_pages_pct=40
  64. innodb_lock_wait_timeout=120
  65. innodb_locks_unsafe_for_binlog=1
  66. innodb_autoinc_lock_mode=2
  67. skip-name-resolve
  68. lower_case_table_names=1
  69. [mysqldump]
  70. quick
  71. max_allowed_packet=16M
  72. [mysql]--phpfensi.com
  73. auto-rehash
  74. [myisamchk]
  75. key_buffer_size=512M
  76. sort_buffer_size=512M
  77. read_buffer=8M
  78. write_buffer=8M
  79. [mysqlhotcopy]
  80. interactive-timeout
  81. [mysqld_safe]
  82. open-files-limit=8192

4.4)异常处理

4.4.1)直接通过mysqld_safe不能正常启动数据库,代码如下:

ln -s /opt/mysql/product/5.5 /usr/local/mysql

或者

ln -s /opt/mysql/product/5.5/bin/mysqld /usr/local/mysql/bin/mysqld

4.4.2)mysql_secure_installation不能正常执行.

1)执行:/opt/mysql/product/5.5/bin/mysql_secure_installation出现以下错误,解决方法(ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock)

Enter current password for root (enter for none):

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

2)修改mysql_secure_installation 脚本的do_query 函数,推荐处理方法,代码如下:

  1. do_query(){
  2. echo“$1″>$command
  3. #sed‘s,^,>,’<$command#Debugging
  4. #mysql--defaults-file=$config<$command----此行修改如下:
  5. mysql--defaults-extra-file=$config<$command
  6. return$?
  7. }

5、添加开机启动服务

修改mysql.server文件,代码如下:

  1. basedir=/opt/mysql/product/5.5
  2. datadir=/opt/mysql/mysqldata
  3. [root@localhost~]#cp/opt/mysql/product/5.5/support-files/mysql.server/etc/init.d/mysqld
  4. [root@localhost~]#chkconfig–addmysqld
  5. [root@localhost~]#chkconfigmysqldon
  6. [root@localhost~]#chkconfig–listmysqld
  7. mysqld0:off1:off2:on3:on4:on5:on6:off

广告内容

linux中mysql 5.5二进制文件安装详解 linux中mysql 5.5二进制文件安装详解 linux中mysql 5.5二进制文件安装详解

相关阅读

热门评论

卢松松博客 卢松松博客

关注创业者、自媒体人和站长的网站

总篇数167

精选文章

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

SEO最新算法