如何下载和安装mysql rpm 程序包
1.建议从MySQL的官方网站下载软件,确保安全和可靠性。
下载链接:https://www.php.cn/link/06d86297d6e28d4637d60c86c2a2f5b6

在下载页面,根据操作系统的版本选择适当的RPM包。此次选择的是适用于Linux 6的RPM包(RPM Bundle)。下载完成后,将其上传到Linux服务器上。使用Tar命令进行解压:
tar -xvf 包名
例如:
-bash-4.1$ tar -xvf mysql-8.0.23-1.el6.x86_64.rpm-bundle.tar mysql-community-client-8.0.23-1.el6.x86_64.rpm mysql-community-client-plugins-8.0.23-1.el6.x86_64.rpm mysql-community-common-8.0.23-1.el6.x86_64.rpm mysql-community-devel-8.0.23-1.el6.x86_64.rpm mysql-community-libs-8.0.23-1.el6.x86_64.rpm mysql-community-libs-compat-8.0.23-1.el6.x86_64.rpm mysql-community-server-8.0.23-1.el6.x86_64.rpm mysql-community-test-8.0.23-1.el6.x86_64.rpm
您可以通过rpm -qpl命令来查看RPM包中的文件内容。
shell> rpm -qpl mysql-community-server-version-distribution-arch.rpm
安装MySQL RPM包可以使用以下命令:
shell> sudo yum install mysql-community-{server,client,common,libs}-*确认安装是否成功,可以通过以下步骤进行检查:
1.查看已安装的MySQL文件:
-bash-4.1$ rpm -qa | grep mysql mysql-community-common-8.0.23-1.el6.x86_64 mysql-community-libs-8.0.23-1.el6.x86_64 mysql-community-server-8.0.23-1.el6.x86_64 mysql-community-client-8.0.23-1.el6.x86_64 mysql-community-client-plugins-8.0.23-1.el6.x86_64 mysql-community-libs-compat-8.0.23-1.el6.x86_64
2.检查MySQL服务的运行状态:
-bash-4.1$ service mysqld status mysqld is stopped
注意:这里使用的是Oracle Linux 6,因此使用service命令来管理服务。
-bash-4.1$ service Usage: service | --status-all | [ service_name [ command | --full-restart ] ]
对于Linux 7及更高版本,可以使用systemctl来管理服务:
systemctl status mysqld.service
启动MySQL服务,在Linux 6上使用service命令:
SmartB2B 是一款基于PHP、MySQL、Smarty的B2B行业电子商务网站管理系统,系统提供了供求模型、企业模型、产品模型、人才招聘模型、资讯模型等模块,适用于想在行业里取得领先地位的企业快速假设B2B网站,可以运行于Linux与Windows等多重服务器环境,安装方便,使用灵活。 系统使用当前流行的PHP语言开发,以MySQL为数据库,采用B/S架构,MVC模式开发。融入了模型化、模板
-bash-4.1$ sudo service mysqld start Initializing MySQL database: [ OK ] Starting mysqld: [ OK ] -bash-4.1$ sudo service mysqld status mysqld (pid 28030) is running...
对于Linux 7及更高版本,使用systemctl命令:
systemctl start mysqld
重置MySQL root用户密码:在服务器首次启动时,会自动创建超级用户账号'root'@'localhost'并设置临时密码,临时密码会存储在错误日志文件中。可以通过以下命令查看:
sudo grep 'temporary password' /var/log/mysqld.log
例如:
-bash-4.1$ sudo grep 'temporary password' /var/log/mysqld.log 2021-02-16T09:16:36.715031Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: u7hf5?5:4hG4
登录并使用临时密码,然后修改密码:
shell> mysql -uroot -p mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '密码';
例如:
-bash-4.1$ mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 8.0.23Copyright (c) 2000, 2021, 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> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; Query OK, 0 rows affected (0.03 sec)
登录确认:
-bash-4.1$ mysql -uroot -pMyNewPass4! mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 11 Server version: 8.0.23 MySQL Community Server - GPLCopyright (c) 2000, 2021, 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.01 sec)
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> select Host,User from user; +-----------+------------------+ | Host | User | +-----------+------------------+ | localhost | mysql.infoschema | | localhost | mysql.session | | localhost | mysql.sys | | localhost | root | +-----------+------------------+ 4 rows in set (0.00 sec)
mysql> SELECT VERSION(), CURRENT_DATE; +-----------+--------------+ | VERSION() | CURRENT_DATE | +-----------+--------------+ | 8.0.23 | 2021-02-16 | +-----------+--------------+ 1 row in set (0.00 sec)
参考资料:https://www.php.cn/link/2804d14b1b70880c48b4cd4882e23ee0









