ITPub博客

首页 > 数据库 > MySQL > mysql5.5安装手册

mysql5.5安装手册

原创 MySQL 作者:wangxuefengwxf 时间:2015-02-12 21:14:46 0 删除 编辑

安装mysql-5.5.24


一、配yum源,装包。
    如果可能的话用阿里云的yum或者是其他的网络yum源。因为有一些包需要下载什么的。

[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

wget在什么目录下执行就下载到哪个目录

安装需要的包 


yum -y install gcc gcc-c autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers bison  gcc-c++ ncurses-devel  


gcc-c++是cmake需要的。因为cmake是由c++编写的。
原理: http://blog.csdn.net/shaoxiaohu1/article/details/9179715


ncurses-devel是依赖,如果没有会报错CMake Error at cmake/readline.cmake:83 (MESSAGE) 
解决: http://blog.163.com/sz2273_pr/blog/static/41264296201361354426670/

bison缺少时会出现   Warning: Bison executable not found in PATH
http://blog.csdn.net/wulantian/article/details/8540800


二、下载cmake。从5.5以后就开始使用cmake,而不是configure。

wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz

安装cmake
[root@localhost local]# tar -zxvf cmake-2.8.4.tar.gz

[root@localhost local]# cd cmake-2.8.4

[root@localhost cmake-2.8.4]#./configure

[root@localhost cmake-2.8.4]# make && make install

三、mysql编译安装。
  1、创建安装目录
  [root@localhost ~]# mkdir -p /usr/local/mysql/

  2、 创建数据存放目录
  [root@localhost ~]# mkdir -p /service/mysql/

  3、创建用户和用户组与赋予数据存放目录权限
 [root@localhost ~]# groupadd mysql

 [root@localhost ~]# useradd -g mysql mysql

  [root@localhost ~]# chown mysql.mysql -R /service/mysql/

  4、解压mysql
  
  下载mysql-5.5.24到/usr/local
  
  [root@localhost local]# tar -zxvf mysql-5.5.24.tar.gz

  [root@localhost local]# cd mysql-5.5.24

  5、编译配置
  [root@localhost mysql-5.5.24]#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
  -DMYSQL_UNIX_ADDR=/service/mysql/mysql.sock \
  -DDEFAULT_CHARSET=utf8 \
  -DDEFAULT_COLLATION=utf8_general_ci \
  -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
  -DWITH_MYISAM_STORAGE_ENGINE=1 \
  -DWITH_INNOBASE_STORAGE_ENGINE=1 \
  -DWITH_MEMORY_STORAGE_ENGINE=1 \
  -DWITH_READLINE=1 \
  -DENABLED_LOCAL_INFILE=1 \
  -DMYSQL_DATADIR=/service/mysql \
  -DMYSQL_USER=mysql \
  -DMYSQL_TCP_PORT=3306
  
 (其实这里,只需要写第一行确认安装目录就行,后面还可以配置。)
  
  [root@localhost mysql-5.5.24]make && make install
  6、复制配置文件
  [root@localhost mysql-5.5.24]# cp support-files/my-medium.cnf /etc/my.cnf

  7、初始化数据库
  (执行前 需要chmod 755 scripts/mysql_install_db 赋给文件执行权限)

  [root@localhost mysql-5.5.24]# scripts/mysql_install_db --user=mysql --  basedir=/usr/local/mysql --datadir=/service/mysql/

  注:#basedir mysql安装路径 datadir 数据库文件储存路径

  8、设置mysqld的开机启动:
  [root@localhost mysql-5.5.24]# cp support-files/mysql.server /etc/init.d/mysqld

  [root@localhost mysql-5.5.24]# chmod 755 /etc/init.d/mysqld

  chkconfig mysqld on (设置开机启动mysql)

  9、 启动mysql服务
  [root@localhost mysql-5.5.24]# /etc/init.d/mysqld start //服务器端开关

  启动完成之后用ps -ef |grep mysql 命令查看是否启动
 
 10、修改root密码
 cd /usr/local/mysql/bin
  ./mysqladmin -u -u root password '123'

  11、[root@localhost bin]# pwd
  /usr/local/mysql/bin
  [root@localhost bin]# ./mysql -u root -p
  Enter password: 
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 6
  Server version: 5.5.24-log Source distribution


  Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.


  Oracle is a registered trademark of Oracle Corporation and/or its
  affiliates. Other names may be trademarks of their respective
  owners.


  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


  mysql> 


  这样就算是安装好了。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29895090/viewspace-1434690/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: oracle体系结构
下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2014-09-18

  • 博文量
    3
  • 访问量
    4200