【MySQL】Ubuntu22.04安装MySQL8数据库详解

2023-11-20

00. 目录


在这里插入图片描述

01. 安装MySQL

1.1 更新软件源

deng@local:~/code/3linux/9mutex_cond$ sudo apt update

1.2 安装mysql-server

deng@local:~/code/3linux/9mutex_cond$ sudo apt install mysql-server

1.3 安装libmysqlclient-dev

deng@local:~/code/3linux/9mutex_cond$ sudo apt install libmysqlclient-dev

02. 配置MySQL

2.1 进入mysql

deng@local:~$ sudo mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.34-0ubuntu0.22.04.1 (Ubuntu)

Copyright (c) 2000, 2023, 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> 


2.2 执行以下命令

然后运行以下 ALTER USER 命令将 root 用户的身份验证方法更改为使用密码的方法。 以下示例将身份验证方法更改为 mysql_native_password:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '12345678';

Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;

2.3 退出MySQL

mysql> quit
Bye
deng@local:~$ 

2.4 以sudo权限运行mysql_secure_installation

deng@local:~$ sudo mysql_secure_installation

Securing the MySQL server deployment.

# 输入密码password
Enter password for user root: 


2.5 设置密码策略和密码

deng@local:~$ sudo mysql_secure_installation

Securing the MySQL server deployment.

# 输入密码password
Enter password for user root: 

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

# 输入Y
Press y|Y for Yes, any other key for No: Y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

# 输入0
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Using existing password for root.

# 输入Y
Estimated strength of the password: 50 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : 


# 输入密码12345678
New password: 

# 输入密码12345678
Re-enter new password: 

Estimated strength of the password: 50 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.


2.6 其它设置

# 输入N
Remove anonymous users? (Press y|Y for Yes, any other key for No) : N

 ... skipping.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

# 输入Y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


# 输入N
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N

 ... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.

All done! 

03. 查看MySQL状态

显示active表示已经在运行

deng@local:~/code/3linux/9mutex_cond$ sudo systemctl status mysql.service
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset:>
     Active: active (running) since Thu 2023-09-07 17:25:26 CST; 10min ago
    Process: 6711 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=e>
   Main PID: 6719 (mysqld)
     Status: "Server is operational"
      Tasks: 39 (limit: 4556)
     Memory: 366.7M
        CPU: 6.904s
     CGroup: /system.slice/mysql.service
             └─6719 /usr/sbin/mysqld

9月 07 17:25:26 local systemd[1]: Starting MySQL Community Server...
9月 07 17:25:26 local systemd[1]: Started MySQL Community Server.
lines 1-14/14 (END)


04. 登录MySQL数据库

执行以下命令

deng@local:~$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.34-0ubuntu0.22.04.1 (Ubuntu)

Copyright (c) 2000, 2023, 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> 

05. 问题讨论

06. 附录

参考: 【数据库】Ubuntu18.04安装MySQL详解

官网: MySQL官网

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

【MySQL】Ubuntu22.04安装MySQL8数据库详解 的相关文章

随机推荐

  • WEB安全测试手册

    概述 目的 适用读者 适用范围 注意事项 测试级别说明 测试过程示意图 1 服务器信息收集 1 1 运行帐号权限测试 1 2 Web服务器端口扫描 1 3 HTTP方法测试 1 4 HTTP PUT方法测试 1 5 HTTP DELETE方
  • 前端例程20211213:网页去色(以灰度形式显示)

    文章目录 前言 实现与演示 前言 在每年的一些特殊的日子 比如公祭日等 很多网站会将页面整体去色以灰度形式显示 以示哀悼 这里将对网页中实现该功能进行简单说明 实现与演示 使用CSS的 filter grayscale 属性可以给元素添加灰
  • 主进程退出后子进程还会存在吗?_深度好文

    干了这碗鸡汤 我急切地盼望着可以经历一场放纵的快乐 纵使巨大的悲哀将接踵而至 我也在所不惜 太宰治 人间失格 大家好 这里是周日凌晨4点 仍在笔耕不辍的程序喵大人 下面隆重推出我呕心沥血 耗时半个月完成的精心力作 01 什么是进程 标准定义
  • Element Plus 配置自动按需引入后,手动引入组件,组件样式丢失

    起因 最近在尝试使用 Element Plus 写一些简单的页面 跟着官方文档走配置了自动按需引入 npm install D unplugin vue components unplugin auto import vite config
  • IDEA全局搜索框打不开,全局搜索不全,全局搜索不到解决办法

    IDEA默认全局搜索快捷键是Ctrl Shift F 当我在使用IDEA的全局搜索时 发现IDEA的全局搜索快捷键不起作用 无法弹出全局搜索框 此时想到了应该是快捷键被占用了 首先想到的就是搜狗输入法 打开搜狗输入法设置 高级 把这个简繁切
  • Python 基于BP神经网络的鸢尾花分类

    本文用Python实现了BP神经网络分类算法 根据鸢尾花的4个特征 实现3种鸢尾花的分类 算法参考文章 纯Python实现鸢尾属植物数据集神经网络模型 2020 07 21更新 增加了分类结果可视化result visualization
  • Elasticsearch 索引模板:优化大数据搜索与分析

    Elasticsearch 是一个强大的分布式搜索和分析引擎 广泛应用于处理大数据量的搜索和分析任务 为了提高搜索效率和数据组织结构的一致性 Elasticsearch 提供了索引模板 template 的功能 索引模板允许我们在创建索引时
  • 《python语言程序设计》第5章 第23题 贷款计算

    LOAN AMOUNT 10000 number years 5 NUMBER OF YEAR number years 12 interest rate 5 month rate interest rate 1200 print f Lo
  • springboot跳转页面

    SpringBoot里面只有src目录 在src main resources下面有两个文件夹 static 和 templates springboot默认static中放静态页面 而templates中放动态页面 themleaf和fr
  • Egret游戏通用开发框架

    地址 https github com yicaoyimuys EgretGameEngine 简介 现在这套代码已经有几个项目都在使用了 主要用于各项目组间统一开发规范 便于开发人员调整 以及新手快速熟悉项目 支持Egret2 0 x和2
  • C#写的34401A串口232数据读取程序

    首先呢 请先设置惠普表为Talk only模式 也就是31 还不明白的自己查手册去 另外 各个表设置不一样 比如我这里2块表就不一样 一块是7位数据位 even校验 另一块是8位数据位 none校验 具体的可以看看表里的i o那里的设置 数
  • GPIO的两种引脚规则:BCM与BOARD

    树莓派 raspberry 针脚在python中BCM与BOARD模式的区别 在python程序中定义的GPI针脚有两种模式 BCM模式 BOARD模式 BCM模式 例如 GPIO setmode GPIO BCM 测试结果如下 物理针脚1
  • pycharm注释快捷键Ctrl+/

    行注释 取消行注释 Ctrl 块注释 Ctrl Shift
  • ArcGIS部分问题解决办法

    ArcGIS部分常见问题解决办法 最近在学习ArcGIS过程中 进行某些操作选项总是会会发生错误 不仅仅我自己一个人是这样 周围好多同学也是经常在操作的过程中报错 所以就很突发奇想把这段时间遇到的问题统一写下来 也是为了自己以后忘掉可以直接
  • 系统调用:用户级函数如何通过INT 80中断进入操作系统内核

    以printf 打印内核中的一段字符串为例 printf 是用户函数无法进入内核 因此需要进行系统调用 进入内核的方式是使用int 0x80中断 printf 函数想要进入系统内核是通过系统调用write 实现 位置 linux lib w
  • Usbkey原理介绍

    不好意思 百度来的 大家一起学习吧 文库中竟然收费5个币 Usbkey原理介绍 一 usbkey实现身份认证原理 采用冲击响应的认证方法 登录时在服务器端和客户端同时进行计算 客户端计算前要先验证USER PIN 通过后在硬件中使用HMAC
  • OD华为机试 23

    篮球比赛 描述 篮球 5V5 比赛中 每个球员拥有一个战斗力 每个队伍的所有球员战斗力之和为该队伍的总体战斗力 现有10个球员准备分为两队进行训练赛 教练希望2个队伍的战斗力差值能够尽可能的小 以达到最佳训练效果 给出10个球员的战斗力 如
  • docker搭建hadoop hdfs完全分布式集群

    1 制作hadoop镜像 参见 https www cnblogs com rmxd p 12051866 html 该博客中只参考制作镜像部分 固定IP及启动集群的部分应该跳过 这里注意 在做好的镜像里 要安装 which 工具 否则在执
  • DFS的个人理解和测试例题

    深度优先搜索 DFS 是一种搜索手段 可以理解为 它从某个位置 起点 开始 沿着一条路不断地向前走直到尽头 然后退后一步 去走其它没走过的路 没有的话 再退后一步 再去选择 直到找到目的地 终点 例如下图 从A 起点 开始走 先走ABD 在
  • 【MySQL】Ubuntu22.04安装MySQL8数据库详解

    00 目录 文章目录 00 目录 01 安装MySQL 02 配置MySQL 03 查看MySQL状态 04 登录MySQL数据库 05 问题讨论 06 附录 01 安装MySQL 1 1 更新软件源 deng local code 3li