如何安装mysql-5.5.31

2013-03-06

根据自己的操作系统,选择对应的mysql安装包。

一、windows如何安装mysql-5.5.31-win32.zip

1、解压缩,比如到d:\,为了方便,改一下路径,比如mysql
2、开始/运行,输入cmd,回车进入命令行
d:
cd mysql\bin
安装mysql服务
mysqld.exe --install (默认服务名称是mysql或者mysqld.exe --install "mysql5"修改服务名称)
删除mysql服务
mysqld.exe --remove(或者mysqld.exe --remove "mysql5")
3、ini参数配置文件d:\mysql\
复制mysql-small.ini为my.ini
4、启动停止服务
a)在命令行启动/停止
net start mysql
net stop mysql
b)或者去控制面板找服务启动
c)或者开始/运行输入services.msc,确定后,找到mysql启动

二、linux如何用源码安装mysql-5.5.31.tar.gz

安装编译环境
#!/bin/bash
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zli
b-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 k
rb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers bison lynx

#!/bin/bash
#wget http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
#wget ftp://61.135.158.279/pub/mysql-5.5.31.tar.gz
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/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 untar/conf/my.cnf /usr/local/mysql/
cp /opt/LNMP/mysql-5.5.31/support-files/my-large.cnf /usr/local/mysql/my.cnf
cp /opt/LNMP/mysql-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;"

分类:Linux数据库 | 标签: |

相关日志

评论被关闭!