如何下载和安装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命令:
-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.23 <p>Copyright (c) 2000, 2021, Oracle and/or its affiliates.</p><p>Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.</p><p>Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.</p><p>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 - GPL</p><p>Copyright (c) 2000, 2021, Oracle and/or its affiliates.</p><p>Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.</p><p>Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.</p><p>mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.01 sec)</p><p>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)</p><p>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
以上就是MySQL入门:Linux 6 RPM方式安装MySQL 8.0的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号