suixinsuoyu 2020-07-19
在下载前,先做以下内容
检测下系统内有没有已经安装过的旧版本的boost库以及MySQL或者mariadb
rpm -qa boost mysql mariadb*
随后将其卸载
yum remove boost* mysql* mariadb* -y
随后创建对应文件夹,并下载对应软件
mkdir /app/pack -p mkdir /app/service -p
将软件包下载到 /app/pack下
cd /app/pack #复制对应连接 wget下载 wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.27.tar.gz wget https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-5.7.27.tar.gz
开始编译
创建MySQL的用户 useradd -M -s /sbin/nologin mysql tar xf mysql-boost-5.7.27.tar.gz cd mysql-5.7.27 cmake -DCMAKE_INSTALL_PREFIX=/app/service/mysql -DMYSQL_DATADIR=/app/service/mysql/data/ -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/app/service/mysql/mysql.sock -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DDEXTRA_CHARSET=utf8 -DEXTRA_CHARSETS=all -DDEFAULT_COLLATION=utf8_general_ci -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/root/mysql-5.7.27/boost/boost_1_59_0 echo $? #返回0则为执行成功 make && make install echo $? ls /app/service/msql 会生成很多对应的目录等
具体编译参数 参考官网 https://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html
自定义配置文件
vi /etc/my.cnf [mysqld] basedir=/app/service/mysql datadir=/app/service/mysql/data port=3306 socket=/app/service/mysql/mysql.sock character-set-server=utf8 log-error=/app/service/mysql/mysqld.log pid-file=/app/service/mysql/mysqld.pid
配置简单启动命令,
cp /app/service/mysql/support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld 修改文件内部分内容 vi /etc/init.d/mysqld basedir=/app/service/mysql datadir=/app/service/mysql/data chown -R mysql.mysql /app/service/mysql vi /etc/profile export PATH=/app/service/mysql/bin:$PATH source /etc/profile
初始化数据库
mysqld --initialize --user=mysql --basedir=/app/service/mysql --datadir=/app/service/mysql/data/
启动数据库
/etc/init.d/mysqld start grep password /app/service/mysql/mysqld.log 2020-07-05T09:00:18.508755Z 1 [Note] A temporary password is generated for : LjqsH>r1p:We 复制末尾的密码 mysql -uroot -pLjqsH>r1p:We 登陆数据库
重置密码
数据库外 mysqladmin -uroot -p password "123qwe" Enter password: #这个是让你输入原密码。若没有原密码,则直接回车掠过 或者在数据库内 alter user identified by ‘123qwe‘;
自此数据库安装成功