MySQL——Linux安装教程

1、使用压缩包中的软件进行mysql的安装

2、使用压缩包中的软件进行mysql的安装

  • 将rpm包所在目录配置成一个yum仓库

[root@bogon ~]# unzip /root/数据库材料.zip -d /mysql-pkg
[root@bogon ~]# ls /mysql-pkg/
mysql-8.0.36-1.el8.x86_64.rpm-bundle.tar                        MySQL-Crashcourse.zip
'MySQL Crash Course, 2nd Edition (Forta, Ben) (Z-Library).pdf'   mysql-workbench-community-8.0.24-1.el8.x86_64.rpm
[root@bogon mysql-pkg]# mkdir mysql-80   
[root@bogon mysql-pkg]# ls
mysql-80  mysql-8.0.36-1.el8.x86_64.rpm-bundle.tar  MySQL-Crashcourse.zip  mysql-workbench-community-8.0.24-1.el8.x86_64.rpm
[root@bogon mysql-pkg]# tar -xf mysql-8.0.36-1.el8.x86_64.rpm-bundle.tar -C ./mysql-80/
[root@bogon mysql-pkg]# ls ./mysql-80/
mysql-community-client-8.0.36-1.el8.x86_64.rpm                    mysql-community-libs-8.0.36-1.el8.x86_64.rpm
mysql-community-client-debuginfo-8.0.36-1.el8.x86_64.rpm          mysql-community-libs-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-client-plugins-8.0.36-1.el8.x86_64.rpm            mysql-community-server-8.0.36-1.el8.x86_64.rpm
mysql-community-client-plugins-debuginfo-8.0.36-1.el8.x86_64.rpm  mysql-community-server-debug-8.0.36-1.el8.x86_64.rpm
mysql-community-common-8.0.36-1.el8.x86_64.rpm                    mysql-community-server-debug-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-debuginfo-8.0.36-1.el8.x86_64.rpm                 mysql-community-server-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-debugsource-8.0.36-1.el8.x86_64.rpm               mysql-community-test-8.0.36-1.el8.x86_64.rpm
mysql-community-devel-8.0.36-1.el8.x86_64.rpm                     mysql-community-test-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-icu-data-files-8.0.36-1.el8.x86_64.rpm
[root@bogon mysql-pkg]# cd mysql-80/
[root@bogon mysql-80]# pwd
/mysql-pkg/mysql-80
[root@bogon mysql-80]# ls
mysql-community-client-8.0.36-1.el8.x86_64.rpm                    mysql-community-libs-8.0.36-1.el8.x86_64.rpm
mysql-community-client-debuginfo-8.0.36-1.el8.x86_64.rpm          mysql-community-libs-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-client-plugins-8.0.36-1.el8.x86_64.rpm            mysql-community-server-8.0.36-1.el8.x86_64.rpm
mysql-community-client-plugins-debuginfo-8.0.36-1.el8.x86_64.rpm  mysql-community-server-debug-8.0.36-1.el8.x86_64.rpm
mysql-community-common-8.0.36-1.el8.x86_64.rpm                    mysql-community-server-debug-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-debuginfo-8.0.36-1.el8.x86_64.rpm                 mysql-community-server-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-debugsource-8.0.36-1.el8.x86_64.rpm               mysql-community-test-8.0.36-1.el8.x86_64.rpm
mysql-community-devel-8.0.36-1.el8.x86_64.rpm                     mysql-community-test-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-icu-data-files-8.0.36-1.el8.x86_64.rpm
[root@bogon mysql-80]# yum -y install dnf-utils createrepo
[root@bogon mysql-80]# createrepo .
Directory walk started
Directory walk done - 17 packages
Temporary output repo path: ./.repodata/
Preparing sqlite DBs
Pool started (with 5 workers)
Pool finished
[root@bogon mysql-80]# ls
mysql-community-client-8.0.36-1.el8.x86_64.rpm                    mysql-community-libs-8.0.36-1.el8.x86_64.rpm
mysql-community-client-debuginfo-8.0.36-1.el8.x86_64.rpm          mysql-community-libs-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-client-plugins-8.0.36-1.el8.x86_64.rpm            mysql-community-server-8.0.36-1.el8.x86_64.rpm
mysql-community-client-plugins-debuginfo-8.0.36-1.el8.x86_64.rpm  mysql-community-server-debug-8.0.36-1.el8.x86_64.rpm
mysql-community-common-8.0.36-1.el8.x86_64.rpm                    mysql-community-server-debug-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-debuginfo-8.0.36-1.el8.x86_64.rpm                 mysql-community-server-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-debugsource-8.0.36-1.el8.x86_64.rpm               mysql-community-test-8.0.36-1.el8.x86_64.rpm
mysql-community-devel-8.0.36-1.el8.x86_64.rpm                     mysql-community-test-debuginfo-8.0.36-1.el8.x86_64.rpm
mysql-community-icu-data-files-8.0.36-1.el8.x86_64.rpm            repodata

[root@bogon mysql-80]# yum-config-manager --add-repo='file:///mysql-pkg/mysql-80' mysql80
Adding repo from: file:///mysql-pkg/mysql-80
[root@bogon mysql-80]# ls /etc/yum.repos.d/
mysql-pkg_mysql-80.repo  qh-yum.repo
[root@bogon mysql-80]# vim /etc/yum.repos.d/mysql-pkg_mysql-80.repo
[mysql-pkg_mysql-80]
name=created by dnf config-manager from file:///mysql-pkg/mysql-80
baseurl=file:///mysql-pkg/mysql-80
enabled=1
#### 新增下面这一行
gpgcheck = 0
[root@bogon mysql-80]# yum install mysql-community-server --repo mysql-pkg_mysql-80

## 等待安装完成即可


 3、启动服务端守护进程

systemctl start mysqld

[root@bogon ~]# systemctl enable --now mysqld.service
[root@bogon ~]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2024-04-02 23:22:30 EDT; 7s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 36725 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 36798 (mysqld)
   Status: "Server is operational"
    Tasks: 38 (limit: 23330)
   Memory: 543.7M
   CGroup: /system.slice/mysqld.service
           └─36798 /usr/sbin/mysqld


Apr 02 23:22:23 bogon systemd[1]: Starting MySQL Server...
Apr 02 23:22:30 bogon systemd[1]: Started MySQL Server.
[root@bogon ~]# grep password /var/log/m
maillog     messages    mysqld.log
[root@bogon ~]# grep password /var/log/mysqld.log
2024-04-03T03:22:27.330915Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: +l#RK5yXy<qi
[root@bogon ~]# mysql -u root -p'+l#RK5yXy<qi'

4、连接数据库mysql

[root@bogon ~]# mysql -u root -p'+l#RK5yXy<qi'            //使用临时密码登录
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 8
Server version: 8.0.36


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> ALTER USER root@localhost IDENTIFIED BY 'Redhat1~';        # 修改密码。临时密码只能登录
Query OK, 0 rows affected (0.01 sec)


mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)


mysql> exit
Bye
[root@bogon ~]# mysql -u root -p'Redhat1~'    #验证自定义密码可用
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 9
Server version: 8.0.36 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> show databases;            // 查询数据库的数量
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)


mysql> exit
Bye

相关推荐

  1. conda 安装教程分享

    2024-04-12 18:40:01       41 阅读
  2. Docker安装教程

    2024-04-12 18:40:01       47 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-12 18:40:01       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-12 18:40:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-12 18:40:01       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-12 18:40:01       20 阅读

热门阅读

  1. 【C语言】:内存函数

    2024-04-12 18:40:01       18 阅读
  2. sipp压测freeswitch第2篇Fs配置

    2024-04-12 18:40:01       14 阅读
  3. c语言中,一些全局变量和局部变量的定义及区别

    2024-04-12 18:40:01       14 阅读
  4. 自动糊测试原理,怎么理解?【UI自动化】

    2024-04-12 18:40:01       17 阅读
  5. Vue3---基础4(响应式数据) Vue2

    2024-04-12 18:40:01       15 阅读
  6. 杨扬小朋友求职

    2024-04-12 18:40:01       15 阅读
  7. 100美元如何做安全防御?

    2024-04-12 18:40:01       14 阅读
  8. MyBatis 执行流程

    2024-04-12 18:40:01       21 阅读
  9. C++中不同变量(内置/类 类型) 的初始化规则

    2024-04-12 18:40:01       18 阅读
  10. @NotEmpty、@NotBlank、@NotNull三种注解的区别

    2024-04-12 18:40:01       16 阅读
  11. 类 对象 对象实例

    2024-04-12 18:40:01       13 阅读