centos7源码编译安装mysql5.7.25

wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.25.tar.gz	下载mysql的包
wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz	(mysql编译环境需要boost文件)
yum -y install ncurses-devel.x86_64 openssl-devel bison gcc gcc-c++.x86_64  make cmake     安装依赖
groupadd mysql	创建mysql组
useradd -r -g mysql -s /bin/false mysql	创建只用于运行mysql程序的mysql用户
tar xf mysql-5.7.25.tar.gz
cd mysql-5.7.25/
tar xf /root/boost_1_59_0.tar.gz

编写参数

cmake . \
-DWITH_BOOST=boost_1_59_0/ \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DSYSCONFDIR=/etc \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DINSTALL_MANDIR=/usr/share/man \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1
	make	编译
	make install	安装
	cd /usr/local/mysql/	(初始化)
	mkdir mysql-files		mysql的必要文件
	chown -R mysql.mysql .	(设置当前文件夹下的文件的所有者和所有组)
	bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data	(初始化指定安装目录和数据目录,产生mysql初始密码)
	bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data	  密码安全初始化
	vim /etc/my.cnf		编写配置文件只留下以下内容
		[mysqld]
		basedir=/usr/local/mysql
		datadir=/usr/local/mysql/data
	cp support-files/mysql.server /etc/init.d/mysqld	 添加启动脚本

systemctl daemon-reload 重启systemctl 让其加载管理mysql
systemctl start mysqld
systemctl enable mysqld
systemctl status mysqld
echo “export PATH=$PATH:/usr/local/mysql/bin” >>/etc/profile 设置环境变量,生成mysql命令
source /etc/profile
mysqladmin -uroot -p’8F<.n;-Mvt4m’ password “Swy123456@” 设置mysql的密码,初始密码在上面初始化中获得

你可能感兴趣的:(centos7源码编译安装mysql5.7.25)