linux安装mariadb-5.5.31步骤

2013-07-18

用mariadb替换mysql渐成趋势.如何用源码安装mariadb-5.5.31.tar.gz

1、wget wallcopper.com/scripts/mariadb_ins.sh
2、脚本内容
#!/bin/bash
#wget http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz -C /opt/LNMP/untar
#wget ftp://61.135.158.199/pub/mariadb-5.5.31.tar.gz -C /opt/LNMP/untar
mkdir -p /opt/LNMP/untar
export LNMP=/opt/LNMP

cd $LNMP

tar zxf untar/cmake-2.8.8.tar.gz
pushd cmake-2.8.8
./bootstrap && gmake && gmake install
popd

groupadd mysql
useradd -g mysql mysql
mkdir -p /usr/local/mysql
mkdir -p /var/lib/mysql
chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql /var/lib/mysql

tar zxf untar/mariadb-5.5.31.tar.gz
#basename mariadb-5.5.31.tar.gz
pushd mariadb-5.5.31
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/var/lib/mysql \
-DMYSQL_USER=mysql

make; make install;
popd

#cp untar/conf/my.cnf /usr/local/mysql/
cp /opt/LNMP/mariadb-5.5.31/support-files/my-large.cnf /usr/local/mysql/my.cnf
cp /opt/LNMP/mariadb-5.5.31/support-files/mysql.server /etc/init.d/mysqld

cd /usr/local/mysql
./scripts/mysql_install_db –datadir=/var/lib/mysql –user=mysql

chmod +x /etc/init.d/mysqld
chkconfig mysqld on
/etc/init.d/mysqld start

./bin/mysqladmin -u root password ’123456′
#./bin/mysqld_safe &

netstat -ntlp |grep 3306

cat >> ~/.bash_profile << EOF export PATH=$PATH:/usr/local/mysql/bin EOF source ~/.bash_profile cat >> /etc/ld.so.conf.d/mysql.conf << EOF /usr/local/mysql/lib EOF cat >> ~/my.sh << EOF
mysql -uroot -p123456 -Dmysql
EOF
chmod 755 ~/my.sh

#删除不必要的用户
mysql -uroot -p123456 -e”drop user ”@’localhost’”
mysql -uroot -p123456 -e”drop user ”@’`hostname`’”
mysql -uroot -p123456 -e”drop user ‘root’@'`hostname`’”
mysql -uroot -p123456 -e”drop user root@’::1′”

#创建数据库
mysql -uroot -p123456 -e”create database postfix”
#创建用户
mysql -uroot -p123456 -e”CREATE USER ‘postfix’@'localhost’ IDENTIFIED BY ’123456′;”
mysql -uroot -p123456 -e”GRANT ALL ON postfix.* TO ‘postfix’@'localhost’;”

#让创建的用户生效
mysql -uroot -p123456 -e”commit”
mysql -uroot -p123456 -e”flush privileges;”

分类:数据库 | 标签: |

相关日志

评论被关闭!