目录
1 环境检查
[root@localhost MysqL]# rpm -qa | grep MysqL
[root@localhost MysqL]# rpm -qa | grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[root@localhost MysqL]# yum remove mariadb-libs-5.5.56-2.el7.x86_64
2 下载MysqL
mysql-5.7.19-1.el7.x86_64.rpm-bundle.tar
3 上传Linux服务器
[root@localhost stage]# pwd
/stage
[root@localhost stage]# ll MysqL-5.7.19-1.el7.x86_64.rpm-bundle.tar
-rw-r--r--. 1 root root 592865280 Sep 29 10:41 MysqL-5.7.19-1.el7.x86_64.rpm-bundle.tar
4 解压缩
tar xvf MysqL-5.7.19-1.el7.x86_64.rpm-bundle.tar -C /stage/MysqL/
[root@localhost stage]# ll MysqL/
total 578984
-rw-r--r--. 1 7155 31415 25085192 Jun 24 08:08 MysqL-community-client-5.7.19-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 278292 Jun 24 08:08 MysqL-community-common-5.7.19-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 3778852 Jun 24 08:08 MysqL-community-devel-5.7.19-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 46236988 Jun 24 08:08 MysqL-community-embedded-5.7.19-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 24077820 Jun 24 08:08 MysqL-community-embedded-compat-5.7.19-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 128296360 Jun 24 08:09 MysqL-community-embedded-devel-5.7.19-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 2238032 Jun 24 08:09 MysqL-community-libs-5.7.19-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 2115696 Jun 24 08:09 MysqL-community-libs-compat-5.7.19-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 55456196 Jun 24 08:09 MysqL-community-minimal-debuginfo-5.7.19-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 171537176 Jun 24 08:09 MysqL-community-server-5.7.19-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 15258732 Jun 24 08:09 MysqL-community-server-minimal-5.7.19-1.el7.x86_64.rpm
-rw-r--r--. 1 7155 31415 118490200 Jun 24 08:10 MysqL-community-test-5.7.19-1.el7.x86_64.rpm
5 安装MysqL
rpm -ivh MysqL-community-server-5.7.19-1.el7.x86_64.rpm --nodeps
rpm -ivh MysqL-community-client-5.7.19-1.el7.x86_64.rpm --nodeps
rpm -ivh MysqL-community-common-5.7.19-1.el7.x86_64.rpm
rpm -ivh MysqL-community-libs-5.7.19-1.el7.x86_64.rpm
rpm -ivh MysqL-community-libs-compat-5.7.19-1.el7.x86_64.rpm
6 启动MysqL
/bin/systemctl start MysqLd.service
启动脚本已经安装了,位置在:
/usr/lib/systemd/system/MysqLd.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
Type=forking
PIDFile=/var/run/MysqLd/MysqLd.pid
# Disable service start and stop timeout logic of systemd for MysqLd service.
TimeoutSec=0
# Execute pre and post scripts as root
PermissionsStartOnly=true
# Needed to create system tables
ExecStartPre=/usr/bin/MysqLd_pre_systemd
# Start main service
ExecStart=/usr/sbin/MysqLd --daemonize --pid-file=/var/run/MysqLd/MysqLd.pid $MysqLD_OPTS
# Use this to switch malloc implementation
EnvironmentFile=-/etc/sysconfig/MysqL
# Sets open_files_limit
LimitNOFILE = 5000
Restart=on-failure
RestartPreventExitStatus=1
PrivateTmp=false
7 找到初始密码
[root@localhost ~]# cat /etc/my.cnf | grep log-error
log-error=/var/log/MysqLd.log
[root@localhost system]# cat /var/log/MysqLd.log | grep password
2017-09-29T15:01:26.846762Z 1 [Note] A temporary password is generated for root@localhost: tX(a<)SYu3JG
8 安全初始化MysqL
/usr/bin/MysqL_secure_installation
Server@234
9 连接测试
MysqL -uroot -p
MysqL> show databases; +--------------------+
| Database | +--------------------+
| information_schema | | MysqL | | performance_schema |
| sys | +--------------------+
4 rows in set (0.00 sec)
done!