mysql linux 下面的安装

tar zxvf cmake-2.8.4.tar.gz && cd cmake-2.8.4 && ./configure && make && make install
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql

tar zxvf /mysql-5.5.24.tar.gz && cd mysql-5.5.24
/usr/local/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DMYSQL_DATADIR=/data/mysql/ -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DMYSQL_USER=mysql -DWITH_DEBUG=0 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DSYSCONFDIR=/etc/ -DWITH_SSL=yes -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=on
make && make install


ln -s /usr/local/mysql/lib/lib* /usr/lib/
ln -s /usr/local/mysql/lib/lib* /usr/local/lib/
/sbin/ldconfig
chmod +w /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql


#\cp -f my-cpp.cnf /etc/my.cnf
chown mysql:mysql /etc/my.cnf


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


cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
/etc/rc.d/init.d/mysqld start


#添加用户跟数据库

/usr/local/mysql/bin/mysqladmin -u root password "newpassword"


/usr/local/mysql/bin/mysql -uroot -pnewpassword -e "create database if not exists serverDB default character set utf8 collate utf8_general_ci;"

/usr/local/mysql/bin/mysql -uroot -pnewpassword -e "grant all on \`serverDB\`.* to 'serverUser'@'%' identified by 'pwd';"

/usr/local/mysql/bin/mysql -uroot -pnewpassword -e "grant SELECT on \`serverDB\`.* to 'serverUser'@'%' identified by 'pwd';"

/usr/local/mysql/bin/mysql -uroot -pnewpassword -e "flush privileges;"

你可能感兴趣的:(mysql linux 下面的安装)