在远程liunx下怎么安装mysql数据库
展开全部
#!/bin/bash
export LNMP=/opt/LNMP
mkdir -p $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/mysql-5.5.31.tar.gz
basename mysql-5.5.31.tar.gz
pushd mysql-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 /opt/LNMP/mysql-5.5.31/support-files/my-small.cnf /usr/local/mysql/my.cnf
cd /usr/local/mysql
./scripts/mysql_install_db --datadir=/var/lib/mysql --user=mysql
cp /opt/LNMP/mysql-5.5.31/support-files/mysql.server /etc/init.d/mysqld
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 USER 'discuz'@'localhost' IDENTIFIED BY '123456';"
mysql -uroot -p123456 -e"GRANT ALL ON discuzx.* TO 'discuz'@'localhost';"
mysql -uroot -p123456 -e"commit"
mysql -uroot -p123456 -e"flush privileges;"
export LNMP=/opt/LNMP
mkdir -p $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/mysql-5.5.31.tar.gz
basename mysql-5.5.31.tar.gz
pushd mysql-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 /opt/LNMP/mysql-5.5.31/support-files/my-small.cnf /usr/local/mysql/my.cnf
cd /usr/local/mysql
./scripts/mysql_install_db --datadir=/var/lib/mysql --user=mysql
cp /opt/LNMP/mysql-5.5.31/support-files/mysql.server /etc/init.d/mysqld
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 USER 'discuz'@'localhost' IDENTIFIED BY '123456';"
mysql -uroot -p123456 -e"GRANT ALL ON discuzx.* TO 'discuz'@'localhost';"
mysql -uroot -p123456 -e"commit"
mysql -uroot -p123456 -e"flush privileges;"
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询