CentOS 7 rpm安装Mysql5.7.19

前端之家收集整理的这篇文章主要介绍了CentOS 7 rpm安装Mysql5.7.19前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

目录

1 环境检查

  1. [root@localhost MysqL]# rpm -qa | grep MysqL
  2. [root@localhost MysqL]# rpm -qa | grep mariadb
  3. mariadb-libs-5.5.56-2.el7.x86_64
  4.  
  5. [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服务器

  1. [root@localhost stage]# pwd
  2. /stage
  3. [root@localhost stage]# ll MysqL-5.7.19-1.el7.x86_64.rpm-bundle.tar
  4. -rw-r--r--. 1 root root 592865280 Sep 29 10:41 MysqL-5.7.19-1.el7.x86_64.rpm-bundle.tar

4 解压缩

  1. tar xvf MysqL-5.7.19-1.el7.x86_64.rpm-bundle.tar -C /stage/MysqL/
  2.  
  3. [root@localhost stage]# ll MysqL/
  4. total 578984
  5. -rw-r--r--. 1 7155 31415 25085192 Jun 24 08:08 MysqL-community-client-5.7.19-1.el7.x86_64.rpm
  6. -rw-r--r--. 1 7155 31415 278292 Jun 24 08:08 MysqL-community-common-5.7.19-1.el7.x86_64.rpm
  7. -rw-r--r--. 1 7155 31415 3778852 Jun 24 08:08 MysqL-community-devel-5.7.19-1.el7.x86_64.rpm
  8. -rw-r--r--. 1 7155 31415 46236988 Jun 24 08:08 MysqL-community-embedded-5.7.19-1.el7.x86_64.rpm
  9. -rw-r--r--. 1 7155 31415 24077820 Jun 24 08:08 MysqL-community-embedded-compat-5.7.19-1.el7.x86_64.rpm
  10. -rw-r--r--. 1 7155 31415 128296360 Jun 24 08:09 MysqL-community-embedded-devel-5.7.19-1.el7.x86_64.rpm
  11. -rw-r--r--. 1 7155 31415 2238032 Jun 24 08:09 MysqL-community-libs-5.7.19-1.el7.x86_64.rpm
  12. -rw-r--r--. 1 7155 31415 2115696 Jun 24 08:09 MysqL-community-libs-compat-5.7.19-1.el7.x86_64.rpm
  13. -rw-r--r--. 1 7155 31415 55456196 Jun 24 08:09 MysqL-community-minimal-debuginfo-5.7.19-1.el7.x86_64.rpm
  14. -rw-r--r--. 1 7155 31415 171537176 Jun 24 08:09 MysqL-community-server-5.7.19-1.el7.x86_64.rpm
  15. -rw-r--r--. 1 7155 31415 15258732 Jun 24 08:09 MysqL-community-server-minimal-5.7.19-1.el7.x86_64.rpm
  16. -rw-r--r--. 1 7155 31415 118490200 Jun 24 08:10 MysqL-community-test-5.7.19-1.el7.x86_64.rpm

5 安装MysqL

  1. rpm -ivh MysqL-community-server-5.7.19-1.el7.x86_64.rpm --nodeps
  2. rpm -ivh MysqL-community-client-5.7.19-1.el7.x86_64.rpm --nodeps
  3. rpm -ivh MysqL-community-common-5.7.19-1.el7.x86_64.rpm
  4. rpm -ivh MysqL-community-libs-5.7.19-1.el7.x86_64.rpm
  5. rpm -ivh MysqL-community-libs-compat-5.7.19-1.el7.x86_64.rpm

6 启动MysqL

  1. /bin/systemctl start MysqLd.service

启动脚本已经安装了,位置在:

  1. /usr/lib/systemd/system/MysqLd.service

脚本内容

  1. [Unit]
  2. Description=MysqL Server
  3. Documentation=man:MysqLd(8)
  4. Documentation=http://dev.MysqL.com/doc/refman/en/using-systemd.html
  5. After=network.target
  6. After=syslog.target
  7.  
  8. [Install]
  9. WantedBy=multi-user.target
  10.  
  11. [Service]
  12. User=MysqL
  13. Group=MysqL
  14.  
  15. Type=forking
  16.  
  17. PIDFile=/var/run/MysqLd/MysqLd.pid
  18.  
  19. # Disable service start and stop timeout logic of systemd for MysqLd service.
  20. TimeoutSec=0
  21.  
  22. # Execute pre and post scripts as root
  23. PermissionsStartOnly=true
  24.  
  25. # Needed to create system tables
  26. ExecStartPre=/usr/bin/MysqLd_pre_systemd
  27.  
  28. # Start main service
  29. ExecStart=/usr/sbin/MysqLd --daemonize --pid-file=/var/run/MysqLd/MysqLd.pid $MysqLD_OPTS
  30.  
  31. # Use this to switch malloc implementation
  32. EnvironmentFile=-/etc/sysconfig/MysqL
  33.  
  34. # Sets open_files_limit
  35. LimitNOFILE = 5000
  36.  
  37. Restart=on-failure
  38.  
  39. RestartPreventExitStatus=1
  40.  
  41. PrivateTmp=false

7 找到初始密码

  1. [root@localhost ~]# cat /etc/my.cnf | grep log-error
  2. log-error=/var/log/MysqLd.log
  3.  
  4. [root@localhost system]# cat /var/log/MysqLd.log | grep password
  5. 2017-09-29T15:01:26.846762Z 1 [Note] A temporary password is generated for root@localhost: tX(a<)SYu3JG

8 安全初始化MysqL

  1. /usr/bin/MysqL_secure_installation
  2.  
  3.  
  4.  
  5. Server@234

9 连接测试

  1. MysqL -uroot -p
  2. MysqL> show databases; +--------------------+
  3. | Database | +--------------------+
  4. | information_schema | | MysqL | | performance_schema |
  5. | sys | +--------------------+
  6. 4 rows in set (0.00 sec)
@H_502_631@

done!

猜你在找的CentOS相关文章