1. 下载安装文件

  1. cd /tmp
  2. wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.25-1.el7.x86_64.rpm-bundle.tar

image.png

2. 解压文件

下载完成之后
image.png

  1. tar -xf mysql-8.0.25-1.el7.x86_64.rpm-bundle.tar

解压完成之后 会有对应 rpm 文件
image.png

  1. mysql-community-client-8.0.25-1.el7.x86_64.rpm
  2. mysql-community-client-plugins-8.0.25-1.el7.x86_64.rpm
  3. mysql-community-common-8.0.25-1.el7.x86_64.rpm
  4. mysql-community-devel-8.0.25-1.el7.x86_64.rpm
  5. mysql-community-embedded-compat-8.0.25-1.el7.x86_64.rpm
  6. mysql-community-libs-8.0.25-1.el7.x86_64.rpm
  7. mysql-community-libs-compat-8.0.25-1.el7.x86_64.rpm
  8. mysql-community-server-8.0.25-1.el7.x86_64.rpm
  9. mysql-community-test-8.0.25-1.el7.x86_64.rpm

image.png

3. rpm 安装

卸载自带的老版本

  1. yum remove -y mariadb-libs.x86_64

image.png

安装依赖库

  1. yum -y install make gcc-c++ cmake bison-devel ncurses-devel libaio libaio-devel numactl

image.png

安装上面解压的文件

一次性复制下面所有命令 并执行

  1. rpm -ivh mysql-community-common-8.0.25-1.el7.x86_64.rpm
  2. rpm -ivh mysql-community-client-plugins-8.0.25-1.el7.x86_64.rpm
  3. rpm -ivh mysql-community-libs-8.0.25-1.el7.x86_64.rpm
  4. rpm -ivh mysql-community-libs-compat-8.0.25-1.el7.x86_64.rpm
  5. rpm -ivh mysql-community-client-8.0.25-1.el7.x86_64.rpm
  6. rpm -ivh mysql-community-server-8.0.25-1.el7.x86_64.rpm

image.png

配置数据库

启动数据库

  1. systemctl start mysqld

image.png

检查mysql 进程

  1. ps -aux | grep mysqld

image.png

查看数据库的默认密码

  1. cat /var/log/mysqld.log | grep password

image.png

配置密码

执行命令

  1. mysql_secure_installation

image.png

image.png
根据提示输入新密码:
image.png
image.png

再次输入密码
image.png

  1. Estimated strength of the password: 100
  2. Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
  3. By default, a MySQL installation has an anonymous user,
  4. allowing anyone to log into MySQL without having to have
  5. a user account created for them. This is intended only for
  6. testing, and to make the installation go a bit smoother.
  7. You should remove them before moving into a production
  8. environment.
  9. Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
  10. Success.
  11. Normally, root should only be allowed to connect from
  12. 'localhost'. This ensures that someone cannot guess at
  13. the root password from the network.
  14. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
  15. Success.
  16. By default, MySQL comes with a database named 'test' that
  17. anyone can access. This is also intended only for testing,
  18. and should be removed before moving into a production
  19. environment.
  20. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
  21. - Dropping test database...
  22. Success.
  23. - Removing privileges on test database...
  24. Success.
  25. Reloading the privilege tables will ensure that all changes
  26. made so far will take effect immediately.
  27. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
  28. Success.
  29. All done!

设置远程登录用户

登录mysql 数据库

  1. mysql -u root -pFanmao54..

image.png

创建远程登录用户:

  1. create user 'fanmao'@'%' identified by 'Afanmao528..';
  2. grant all privileges on *.* to 'fanmao'@'%';

image.png
使用用户fanmao
密码 Afanmao528..
登录

image.png

image.png