mysql快速安装

一、快速安装mysql准备工作

首先需要保证自己的开发工具包已安装;未安装使用

yum  groupinstall  'Develop Tools '  -y

这样就不会出现缺少gcc和  No curses/termcap library found

安装过程出现configure: WARNING: unrecognized options: --with-innodb

需要更改参数。如下

二、软件包为mysql-5.1.52.tar.gz

放在/root下面。

vi mysql.sh

#!/bin/sh
groupadd mysql;
useradd mysql -g mysql -s /sbin/nologin -d /dev/null -M -c "just for mysql";
cd /root/
tar -zxvf mysql-5.1.52.tar.gz;
cd mysql-5.1.52;
./configure --prefix=/usr/local/mysql     \
                    --without-debug                   \
                    --with-pthread                    \
          --with-plugins=partition,blackhole,heap,innobase,myisam,ndbcluster            \
                    --with-big-tables                 \
                    --with-extra-charsets=all         \
                    --with-mysqld-ldflags=-rdynamic  \
                    --with-client-ldflags=-all-static \
                    --enable-assembler                \
                    --enable-local-infile             \
                    --enable-thread-safe-client      \
           
make ; make install;
/usr/local/mysql/bin/mysql_install_db  --user=mysql; chown -R root /usr/local/mysql;
chown -R mysql /usr/local/mysql/var;
chgrp -R mysql /usr/local/mysql;
cp /root/mysql-5.1.52/support-files/mysql.server /etc/init.d/mysqld;
chmod 755 /etc/init.d/mysqld;
chkconfig --add mysqld;
service mysqld restart;
/usr/local/mysql/bin/mysqladmin -u root password 'tomcat2008';
cp /root/mysql-5.1.52/support-files/my-medium.cnf /etc/my.cnf;

安装好后vi  /etc/profile

export PATH=/usr/local/mysql/bin:$JAVA_HOME/bin:$PATH

保存退出

source /etc/profile

如果查看安装innodb是否成功:

mysql -pmysql2011

show engines;


安装多个mysql如何在一台机子上安装多台mysql
其实方法同上。只需要修改/etc/my.cnf的名字。配置文件可改为/etc/my3310.cnf
如何启动mysql呢。
/usr/share/mysql/my-medium.cnf

/usr/local/mysql3310/bin/mysqld_safe --defaults-file=/etc/my3310.cnf  --user=mysql &
如果给新的mysql2增加密码 /usr/local/mysql3310/bin/mysqladmin -u root password 'tomcat2008' --socket=/tmp/mysql3310.sock

如何登录:/usr/local/mysql3310/bin/mysql -uroot -ptomcat2008 --socket=/tmp/mysql3310.sock


SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');

你可能感兴趣的:(mysql)