CentOS6.5下二进制安装mysql-5.6.27

前端之家收集整理的这篇文章主要介绍了CentOS6.5下二进制安装mysql-5.6.27前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

感谢分享:http://blog.csdn.net/zq9017197/article/details/49871973

  1. MysqL的安装分为三种:1、RPM包安装;2、二进制包安装;3、源码安装。
  2. 第一种方式比较简单,直接RPM包安装就OK了,或者通过yum源来安装,而第三种方式比较复杂。
  3. 一般项目中使用比较多的是通过二进制包来安装,这种安装方式可以根据企业的不同需求进行相关的自定义配置,比如安装在哪个目录,如何配置等。
  4. 现在具体介绍一下MysqL的二进制安装方式
  5. 1:查看系统版本
  6. [root@CentOS~]#cat/etc/redhat-release
  7. CentOSrelease6.5(Final)
  8. 2:添加用户和组
  9. [root@CentOSMysqL]#groupaddMysqL
  10. [root@CentOSMysqL]#useradd-r-gMysqLMysqL
  11. 3:安装MysqL到/usr/local/MysqL
  12. [root@CentOS~]#cd/tmp
  13. [root@CentOStmp]#llMysqL-5.6.27-linux-glibc2.5-i686.tar.gz
  14. -rw-r--r--.1rootroot30405622611月1704:12MysqL-5.6.27-linux-glibc2.5-i686.tar.gz
  15. [root@CentOStmp]#tarzxfMysqL-5.6.27-linux-glibc2.5-i686.tar.gz-C/usr/local/
  16. [root@CentOStmp]#cd/usr/local/
  17. [root@CentOSlocal]#mvMysqL-5.6.27-linux-glibc2.5-i686/MysqL
  18. [root@CentOSlocal]#chown-RMysqL:MysqLMysqL/
  19. [root@CentOSMysqL]#mkdir/mydata
  20. [root@CentOSMysqL]#chown-RMysqL:MysqL/mydata
  21. 4:初始化MysqL
  22. [root@CentOS/]#cd/usr/local/MysqL
  23. [root@CentOSMysqL]#./scripts/MysqL_install_db--user=MysqL--basedir=/usr/local/MysqL--datadir=/mydata
  24. [root@CentOSMysqL]#chown-RMysqL:MysqL*
  25. 5:修改MysqL配置文件
  26. [root@CentOSMysqL]#cd/usr/local/MysqL
  27. [root@CentOSMysqL]#cpsupport-files/my-default.cnf/etc/my.cnf##注:如果/etc/my.cnf文件存在,则覆盖。
  28. [root@CentOSMysqL]#vi/etc/my.cnf
  29. [client]
  30. password=123456
  31. port=3306
  32. default-character-set=utf8
  33. [MysqLd]
  34. datadir=/mydata
  35. port=3306
  36. character_set_server=utf8
  37. character_set_client=utf8
  38. collation-server=utf8_general_ci
  39. lower_case_table_names=1
  40. max_connections=1000
  41. [MysqL]
  42. 6:为MysqL提供服务脚本
  43. [root@CentOSMysqL]#cd/usr/local/MysqL
  44. [root@CentOSMysqL]#cpsupport-files/MysqL.server/etc/rc.d/init.d/MysqLd
  45. 7:添加开启自启
  46. [root@CentOSinit.d]#chkconfig--addMysqLd
  47. [root@CentOSinit.d]#chkconfigMysqLdon
  48. 8:启动MysqL
  49. [root@CentOSinit.d]#serviceMysqLdstart
  50. StartingMysqL...[确定]
  51. [root@CentOSinit.d]#serviceMysqLdstatus
  52. MysqLrunning(2068)[确定]
  53. 9:添加环境变量
  54. [root@CentOSbin]#vi/etc/profile
  55. PATH=/usr/local/MysqL/bin:/usr/local/MysqL/lib:$PATH
  56. exportPATH
  57. [root@CentOSinit.d]#ln-s/usr/local/MysqL/bin/MysqL/usr/bin
  58. 10:登录MysqL修改密码删除用户(密码为空)
  59. [root@CentOSinit.d]#MysqL-uroot-p-S/tmp/MysqL.sock
  60. MysqL>selectuser,host,passwordfromMysqL.user;
  61. +------+-----------+----------+
  62. |user|host|password|
  63. |root|localhost||
  64. |root|centos||
  65. |root|127.0.0.1||
  66. |root|::1||
  67. ||localhost||
  68. ||centos||
  69. +------+-----------+----------+
  70. 6rowsinset(0.00sec)
  71. MysqL>updateMysqL.usersetpassword=PASSWORD('123456')whereuser='root';
  72. +------+-----------+-------------------------------------------+
  73. |root|localhost|*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9|
  74. |root|centos|*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9|
  75. |root|127.0.0.1|*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9|
  76. |root|::1|*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9|
  77. +------+-----------+-------------------------------------------+
  78. MysqL>dropuser''@localhost;
  79. ||centos||
  80. MysqL>useMysqL
  81. MysqL>updateusersethost='%'whereuser='root'andhost='localhost';
  82. QueryOK,1rowaffected(0.00sec)
  83. Rowsmatched:1Changed:1Warnings:0
  84. |root|%|*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9|
  85. 5rowsinset(0.00sec)
  86. MysqL>FLUSHPRIVILEGES;
  87. 参考:
  88. http://blog.csdn.net/cnyyx/article/details/45151693
  89. //www.cnblogs.com/xiaoit/p/3988640.html

猜你在找的CentOS相关文章