Ps: 此文档记录安装mysql5.5.21的步骤,留待参考

         Mysql安装在独立的位置/usr/local/mysql

安装环境:virtualboxredhat(rhel6.0)

安装方式:源码方式

步骤:

         创建目录/usr/local/mysql

         mkdir –p /usr/local/mysql

         添加启动mysql的用户/用户组

         groupadd mysql

         useradd –g mysql mysql                    //mysql添加到mysql组中

        

         解压安装包

         tar zxvf mysql-5.5.21.tar.gz -C /usr/local/

         cd /usr/local/

         ln -s mysql-5.5.21 mysql

        

         ps:    centos默认未安装gcc,这导致后面的编译无法通过,若你也使用默认方式,请先安装gcc

               检查是否安装gcc                rpm –qa|grep gcc

                  Mysql5.5后通过cmake来编译,所以需要下载安装

                   下载地址:http://www.cmake.org/cmake/resources/software.html

              选择unix/linux sourcetar.gz的最新版本,此时是2.8.7

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

           安装cmake

                   tar zxvf cmake-2.8.7.tar.gz

                   cd cmake-2.8.7

                   ./configure -prefix=/usr/local/cmake

                  make && make install

                   ./configure –prefix=/usr/local/cmake后面这个安装路径可以按照需要来配置,配置的话,在使用cmake的时候需要加绝对路径)

      

         创建mysql授权表

                   mkdir /usr/local/mysql-5.5.21/data

 

                   chown -R mysql:mysql /usr/local/mysql

                   chown -R mysql:mysql /usr/local/mysql-5.5.21

         cd /usr/local/mysql

         cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.5.21 -DMYSQL_DATADIR=/usr/local/mysql-5.5.21/data -DMYSQL_UNIX_ADDR=/usr/local/mysql-5.5.21/mysql.sock -DSYSCONFDIR=/usr/local/mysql-5.5.21/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_TCP_PORT=3306

         make && make install

cp support-files/my-medium.cnf /etc/my.cnf

 

打开my.cnf

vi /etc/my.cnf
[mysqld]下面添加
basedir = /usr/local/mysql-5.5.21
datadir = /usr/local/mysql-5.5.21/data
log-error = /usr/local/mysql-5.5.21/mysql_error.log
pid-file = /usr/local/mysql-5.5.21/data/mysql.pid
default-storage-engine=MyISAM
user = mysql

 

chmod 755 scripts/mysql_install_db

./scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql-5.5.21/ –datadir=/usr/local/mysql-5.5.21/data/

 

设置mysqld开机启动

方法1

cp support-files/mysql.server /etc/init.d/mysqld

chmod 755 /et c/init.d/mysqld

chkconfig mysqld on

 

方法2

将下行加入 /etc/rc.local 文件中,让mysql开机自动启动

/usr/local/mysql-5.5.21/bin/mysqld_safe –user=mysql –default-file=/etc/my.cnf &

 

修改root的密码:

本例中密码是123456

mysqladmin –defaults-file=/etc/my.cnf -u root password ’123456′

创建一个demo数据库

mysqladmin –defaults-file=/etc/my.cnf -u root -p create demo

增加一个demo用户,本例中密码是123456

/usr/local/ /mysql -u root -p

>grant all privileges  on  demo.*  to  demo‘@’localhost’  identified by  ’123456′;

>grant all privileges  on  demo.*  to  demo‘@’%’  identified  by  ’123456′;

> quit

 

数据库初始化,创建数据表文件demo.sql

mysql –u demo –p

use demo;

source demo.sql

quit

标签: ,
本文连接地址: http://www.fresker.com/old2/archives/468 (转载注明出处)

回复

目前暂无评论

Sorry, 评论已关闭.