关机
关机之后先把本台虚拟机的处理器的数量改大一些根据自己电脑cpu,处理器数量越大编译安装时越快,因为Mysql的编译安装非常慢所以要设置核数(右击本台虚拟机 --> 设置 --> 处理器 --> 把处理器数量调成4或更高)
1.配ip,关防火墙,关闭内核安全机制
2.mkdir /media/cdrom
(1)mount /dev/cdrom /media/cdrom
(2)cd /etc/yum.repos.d
(3)mkdir bak
(4)mv C* bak
(5)cp bak/CentOS-Media.repo ./
3.vi CentOS-Media.repo
4.yum clean all && yum makecache
5.yum install -y vim sysstat net-tools bash-completion lrzsz (安装vim命令,ifconfig命令,托包rzsz)
把压缩包托过来(cmake-3.16.2.tar.gz mysql-5.7.28.tar.gz boost_1_59_0.tar.gz)
包都在我主页的资源里
6.rpm -qa |grep mariad
7.yum -y remove mariadb-libs
8.yum install -y make gcc gcc-c++ ncurses-devel openssl-devel
9.tar zxvf cmake-3.16.2.tar.gz -C /usr/src
(1)cd /usr/src/cmake-3.16.2
10. ./configure && gmake && gmake install
11.tar zxvf boost_1_59_0.tar.gz
12.mv boost_1_59_0 /usr/local/boost
13.groupadd mysql
14.useradd -M -s /sbin/nologin -g mysql mysql
15.tar zxvf mysql-5.7.28.tar.gz -C /usr/src
(1)cd /usr/src/mysql-5.7.28
16.cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_BOOST=/usr/local/boost
echo $?
17.make && make install
18.vim /etc/my.cnf
[client]
socket=/usr/local/mysql/data/mysql.sock
[mysqld]
server-id=1
log-bin=mysql-bin
socket=/usr/local/mysql/data/mysql.sock
bind-address=0.0.0.0
skip-name-resolve
port=3306
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
max_connections=2048
character-set-server=utf8
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M
19. /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local
/mysql --datadir=/usr/local/mysql/data
20. echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
(1)source /etc/profile (source /etc/profile)
21. cp /usr/src/mysql-5.7.28/support-files/mysql.server /etc/rc.d/init.d/mysqld
22. chmod +x /etc/rc.d/init.d/mysqld
23. vim /lib/systemd/system/mysqld.service
[Unit]
Description=mysqld
After=network.target
[Service]
Type=forking
ExecStart=/etc/rc.d/init.d/mysqld start
ExecReload=/etc/rc.d/init.d/mysqld restart
ExecStop=/etc/rc.d/init.d/mysqld stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
24. systemctl daemon-reload (重载配置)
25. systemctl enable mysqld
26. systemctl start mysqld
27. netstat -anpt |grep mysqld
28. mysql -uroot -p
(1)exit
29.mysqladmin -u root -p password ‘123456’
(1)mysql -uroot -p
(2)show databases;
(3)\s (查看数据库状态)