LAMP、LNMP实战之四搭建mysql
说明:服务器192.168.2.32
数据库版本mysql5.5.32
cmake版本2.8.8
yum install -y gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* //安装编译环境gcc
yum install -y mysql-devel //安装msyqlku
yum install lrzsz -y //安装上传、下载工具
mkdir /home/www/tools -p //在32上创建目录
cd /home/www/tools/ //进入目录
rz上传cmake-2.8.8.tar.gz和mysql-5.5.32.tar.gz
tar xf cmake-2.8.8.tar.gz //解压make
cd cmake-2.8.8 //进入cmake目录
./configure && gmake && gmake install //编译cmake
cd .. //退出cmake目录
useradd mysql -s /sbin/nologin -M //创建用户属于mysql组
tar xf mysql-5.5.32.tar.gz //解压mysql
cd mysql-5.5.32 //进入mysql目录
输入以下内容并回车
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \
-DMYSQL_DATADIR=/application/mysql-5.5.32/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0
make && make install //安装mysql
ln -s /application/mysql-5.5.32/ /application/mysql //创建软连接
cd .. //退出mysql目录
cp mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf
按y
echo ‘export PATH=/application/mysql/bin:$PATH‘ >>/etc/profile //编辑环境变量
source /etc/profile //即时生效
chown -R mysql.mysql /application/mysql/data/ //用户赋权
chmod -R 1777 /tmp/ //文件夹赋权
cd /application/mysql/scripts/ //进入初始化目录
./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql //初始化mysql
cd /home/www/tools/mysql-5.5.32 //进入目录
cp support-files/mysql.server /etc/init.d/mysqld //创建开机自启动文件
chmod +x /etc/init.d/mysqld //文件夹赋权
/etc/init.d/mysqld start //启动mysql服务
/application/mysql//bin/mysqladmin -u root password ‘oldboy123‘ //添加密码
mysql -uroot -poldboy123 //进入mysql
select user,host from mysql.user; //查看是否有空用户
grant all privileges on test.* to ‘root‘@‘192.168.%‘ identified by ‘oldboy123‘; //配置远程访问
quit //退出mysql
chkconfig mysqld on //设置开机启动