1.版本阐明和引用
- Linux版本Centos7
- [root@localhost ~]# cat /proc/version
- Linux version 3.10.0-1160.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Mon Oct 19 16:18:59 UTC 2020
复制代码 - Mysql版本8.4.0
- 安装方式手动rpm包安装
- 官方安装引导文档,其它系统和版本可参考文档MySQL :: MySQL 8.4 Reference Manual :: 2.5.4 Installing MySQL on Linux Using RPM Packages from Oracle
- 下载Mysql rpm包 MySQL :: Download MySQL Community Server (Archived Versions)
同时支持Linux8/9 选择相应版本下载
Bundle版本意思为合集,ARM和X86为系统架构,正常情况下是X86系统(Inter使用这个)
- 导入虚拟机
- [root@localhost opt]# pwd
- /opt
- [root@localhost opt]# ls
- mysql-8.4.0-1.el7.x86_64.rpm-bundle.tar
复制代码 - 解压压缩包
- [root@localhost opt]# tar xvf mysql-8.4.0-1.el7.x86_64.rpm-bundle.tar
- mysql-community-client-8.4.0-1.el7.x86_64.rpm
- mysql-community-client-plugins-8.4.0-1.el7.x86_64.rpm
- mysql-community-common-8.4.0-1.el7.x86_64.rpm
- mysql-community-debuginfo-8.4.0-1.el7.x86_64.rpm
- mysql-community-devel-8.4.0-1.el7.x86_64.rpm
- mysql-community-embedded-compat-8.4.0-1.el7.x86_64.rpm
- mysql-community-icu-data-files-8.4.0-1.el7.x86_64.rpm
- mysql-community-libs-8.4.0-1.el7.x86_64.rpm
- mysql-community-libs-compat-8.4.0-1.el7.x86_64.rpm
- mysql-community-server-8.4.0-1.el7.x86_64.rpm
- mysql-community-server-debug-8.4.0-1.el7.x86_64.rpm
- mysql-community-test-8.4.0-1.el7.x86_64.rpm
复制代码 - 全部rmp包内容如下
- MysqlRPM包 Rpm包名
简介mysql-community-client客户端和工具包mysql-community-client-plugins客户端共享插件mysql-community-common客户/服务端共享库文件mysql-community-devel客户端开发者头/库文件mysql-community-embedded-compat嵌入式相关支持mysql-community-icu-data-files正则相关的ICU支持文件mysql-community-libs客户端/应用库文件mysql-community-libs-compat旧版兼容相关库文件mysql-community-server服务端和工具包mysql-community-server-debug服务调试和插件相关mysql-community-test服务器测试相关mysql-community源码文件Additional *debuginfo* RPMs可能还有其它debuginfo相关的rmp包
2.安装数据库
- 安装相应rpm包
- [root@localhost opt]# ls
- mysql-8.4.0-1.el7.x86_64.rpm-bundle.tar
- mysql-community-client-8.4.0-1.el7.x86_64.rpm
- mysql-community-client-plugins-8.4.0-1.el7.x86_64.rpm
- mysql-community-common-8.4.0-1.el7.x86_64.rpm
- mysql-community-debuginfo-8.4.0-1.el7.x86_64.rpm
- mysql-community-devel-8.4.0-1.el7.x86_64.rpm
- mysql-community-embedded-compat-8.4.0-1.el7.x86_64.rpm
- mysql-community-icu-data-files-8.4.0-1.el7.x86_64.rpm
- mysql-community-libs-8.4.0-1.el7.x86_64.rpm
- mysql-community-libs-compat-8.4.0-1.el7.x86_64.rpm
- mysql-community-server-8.4.0-1.el7.x86_64.rpm
- mysql-community-server-debug-8.4.0-1.el7.x86_64.rpm
- mysql-community-test-8.4.0-1.el7.x86_64.rpm
- [root@localhost opt]# pwd
- /opt
- [root@localhost opt]# yum install mysql-community-{server,client,client-plugins,icu-data-files,common,libs}-*
复制代码
- 自动安装后默认设置如下
-
Files or Resources
LocationClient programs and scripts/usr/binmysqld server/usr/sbinConfiguration file(设置文件)/etc/my.cnfData directory/var/lib/mysqlError log file(错误日志) For RHEL, Oracle Linux, CentOS or Fedora platforms: /var/log/mysqld.log
For SLES: /var/log/mysql/mysqld.log
Value of secure_file_priv/var/lib/mysql-filesSystem V init script For RHEL, Oracle Linux, CentOS or Fedora platforms: /etc/init.d/mysqld
For SLES: /etc/init.d/mysql
Systemd service For RHEL, Oracle Linux, CentOS or Fedora platforms: mysqld
For SLES: mysql
Pid file/var/run/mysql/mysqld.pidSocket/var/lib/mysql/mysql.sockKeyring directory/var/lib/mysql-keyringUnix manual pages/usr/share/manInclude (header) files/usr/include/mysqlLibraries/usr/lib/mysqlMiscellaneous support files (for example, error messages, and character set files)/usr/share/mysql
- 启动停止Mysql
- [root@localhost opt]# systemctl start mysqld
- [root@localhost opt]# systemctl restart mysqld
- [root@localhost opt]# systemctl stop mysqld
复制代码 - 查看临时密码
- [root@localhost opt]# grep 'temporary password' /var/log/mysqld.log
- 2024-08-13T02:20:22.872261Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: &9Y,cyZl_/gP
复制代码 - 登陆mysql
- [root@localhost opt]# mysql -uroot -p
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 10
- Server version: 8.4.0 MySQL Community Server - GPL
- Copyright (c) 2000, 2024, Oracle and/or its affiliates.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- mysql>
复制代码 - 修改密码(validate_password插件默认安装要求密码强度至少包含一个大写字母、一个小写字母、一位数字和一个特殊字符,并且密码总长度至少为8个字符)
- mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
复制代码 - 修改长途连接
- mysql> use mysql
- Reading table information for completion of table and column names
- You can turn off this feature to get a quicker startup with -A
- Database changed
- mysql> update user set host="%" where user="root";
- Query OK, 0 rows affected (0.00 sec)
- Rows matched: 1 Changed: 0 Warnings: 0
复制代码 - 开放防火墙3306端口
- [root@localhost local]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
- [root@localhost local]# firewall-cmd --reload
- [root@localhost local]# firewall-cmd --list-ports 查看所有开放的端口
复制代码 - 把密码强度修改为简单密码,修改文件后重启Mysql服务后登陆,再次修改密码可以设置简单密码,参见步骤4,6,7(可选)
- [root@localhost opt]# vi /etc/my.cnf
- # For advice on how to change settings please see
- # http://dev.mysql.com/doc/refman/8.4/en/server-configuration-defaults.html
- [mysqld]
- #
- # Remove leading # and set to the amount of RAM for the most important data
- # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
- # innodb_buffer_pool_size = 128M
- #
- # Remove the leading "# " to disable binary logging
- # Binary logging captures changes between backups and is enabled by
- # default. It's default setting is log_bin=binlog
- # disable_log_bin
- #
- # Remove leading # to set options mainly useful for reporting servers.
- # The server defaults are faster for transactions and fast SELECTs.
- # Adjust sizes as needed, experiment to find the optimal values.
- # join_buffer_size = 128M
- # sort_buffer_size = 2M
- # read_rnd_buffer_size = 2M
- datadir=/var/lib/mysql
- socket=/var/lib/mysql/mysql.sock
- bind-address=0.0.0.0
- log-error=/var/log/mysqld.log
- pid-file=/var/run/mysqld/mysqld.pid
- #设置密码强度策略为低
- validate_password.policy=LOW
- #设置密码长度为6个
- validate_password.length=6
复制代码 - 添加本机免密登陆(可选)
- [root@localhost opt]# vi /etc/my.cnf
- # For advice on how to change settings please see
- # http://dev.mysql.com/doc/refman/8.4/en/server-configuration-defaults.html
- [mysqld]
- #
- # Remove leading # and set to the amount of RAM for the most important data
- # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
- # innodb_buffer_pool_size = 128M
- #
- # Remove the leading "# " to disable binary logging
- # Binary logging captures changes between backups and is enabled by
- # default. It's default setting is log_bin=binlog
- # disable_log_bin
- #
- # Remove leading # to set options mainly useful for reporting servers.
- # The server defaults are faster for transactions and fast SELECTs.
- # Adjust sizes as needed, experiment to find the optimal values.
- # join_buffer_size = 128M
- # sort_buffer_size = 2M
- # read_rnd_buffer_size = 2M
- datadir=/var/lib/mysql
- socket=/var/lib/mysql/mysql.sock
- bind-address=0.0.0.0
- log-error=/var/log/mysqld.log
- pid-file=/var/run/mysqld/mysqld.pid
- validate_password.policy=LOW
- validate_password.length=6
- #密码用户名写在[client]下
- [client]
- user=root
- password=123456
复制代码
直接使用mysql命令可以登陆命令行无需再输入密码
- [root@localhost opt]# mysql
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 12
- Server version: 8.4.0 MySQL Community Server - GPL
- Copyright (c) 2000, 2024, Oracle and/or its affiliates.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- mysql>
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |