2021-Centos7.6编译安装mysql-5.7.30
环境
root@c7-105 ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) [root@c7-105 ~]# ls /home/tools/ mysql-5.7.30 mysql-boost-5.7.30.tar.gz
前置包安装
yum install cmake libaio -y
yum install -y gcc-c++ bison-devel ncurses-devel bison perl perl-devel perl perl-devel
yum install openssl openssl-devel ncurses ncurses-devel -y
安装
#ls /home/tools #tar -xf mysql-boost-5.7.30.tar.gz #cd mysql-5.7.30/ #cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.7.30/ \ -DMYSQL_DATADIR=/data/ \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DSYSCONFDIR=/etc \ -DWITH_BOOST=boost \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DWITH_SSL=system \ -DWITH_ZLIB=bundled \ -DENABLED_LOCAL_INFILE=1 \ -DDEFAULT_CHARSET=utf8 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_DEBUG=0 #ln -s /usr/local/mysql-5.7.30/ /usr/local/mysql #chown -R mysql.mysql /usr/local/mysql #cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld # cp /etc/{my.cnf,my.cnfbk} #>my.cnf #vi my.cnf [client] port=3306 default-character-set=utf8 socket=/tmp/mysql.sock [mysqld] basedir=/usr/local/mysql datadir=/data port=3306 socket=/tmp/mysql.sock character-set-server=utf8 explicit_defaults_for_timestamp=true innodb_file_per_table = 1 #echo 'export PATH=/usr/local/mysql/bin:$PATH' >>/etc/profile #source /etc/profile /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data 2021-01-14T14:30:21.046334Z 1 [Note] A temporary password is generated for root@localhost: pl,l*<0;WI/: [root@c7-105 data]# /etc/init.d/mysqld start Starting MySQL.Logging to '/data/c7-105.err'. SUCCESS!
进入数据库更改密码
mysql> alter user user() identified by "******";
使用systemd管理mysql
#vi /usr/lib/systemd/system/mysql.service [Unit] Description=MySQL Server Documentation=man:mysqld(8) Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html After=network.target After=syslog.target [Install] WantedBy=multi-user.target [Service] User=mysql Group=mysql ExecStart=/usr/local/mysql/bin/mysqld --defaults=/etc/my.cnf LimitNOFILE = 5000 #systemctl daemon-reload