LAMP、LNMP实战之四搭建mysql
说明:服务器192.168.2.32 数据库版本mysql5.5.32 cmake版本2.8.8yum install -y gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* //安装编译环境gccyum install -y mysql-devel //安装msyqlkuyum 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.gztar xf cmake-2.8.8.tar.gz //解压makecd cmake-2.8.8 //进入cmake目录./configure && gmake && gmake install //编译cmakecd .. //退出cmake目录useradd mysql -s /sbin/nologin -M //创建用户属于mysql组tar xf mysql-5.5.32.tar.gz //解压mysqlcd 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=0make && 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按yecho '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 //初始化mysqlcd /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 //进入mysqlselect user,host from mysql.user; //查看是否有空用户grant all privileges on test.* to 'root'@'192.168.%' identified by 'oldboy123'; //配置远程访问quit //退出mysqlchkconfig mysqld on //设置开机启动