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

news2024/9/21 0:33:46

🔥博客主页 小羊失眠啦.
🎥系列专栏《C语言》 《数据结构》 《C++》 《Linux》《MySQL》《Qt》
❤️感谢大家点赞👍收藏⭐评论✍️


一、安装目录

1.1 更新软件源

sheep@Aron:/root$ sudo apt update

1.2 安装mysql_server

sheep@Aron:/root$ sudo apt install mysql-server

1.3 安装libmysqlclient-dev

sheep@Aron:/root$ sudo apt install libmysqlclient-dev

二、配置MySQL

2.1 进入MySQL

sheep@Aron:/root$ mysql -uroot -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 20
Server version: 8.0.37-0ubuntu0.22.04.3 (Ubuntu)

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> 


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> exit
Bye
sheep@Aron:/root$

2.4 以sudo权限运行mysql_secure_installation

sheep@Aron:/root$ sudo mysql_secure_installation

Securing the MySQL server deployment.

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


2.5 设置密码策略和密码

sheep@Aron:/root$ 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! 


三、 查看MySQL

显示active表示已经在运行

sheep@Aron:/root$ sudo systemctl status mysql.service
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2024-07-18 15:19:39 CST; 4h 14min ago
   Main PID: 5806 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 1891)
     Memory: 362.0M
        CPU: 1min 4.121s
     CGroup: /system.slice/mysql.service
             └─5806 /usr/sbin/mysqld

Jul 18 15:19:38 Aron systemd[1]: Starting MySQL Community Server...
Jul 18 15:19:39 Aron systemd[1]: Started MySQL Community Server.

四、登录MySQL数据库

sheep@Aron:/root$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 21
Server version: 8.0.37-0ubuntu0.22.04.3 (Ubuntu)

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> 

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1945418.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

手持式气象监测设备

手持式气象监测设备以其小巧轻便、功能齐全的特点,逐渐成为了现代气象观测的便携新选择。 一、手持式气象监测设备的优势 手持式气象监测设备最大的优势在于其便携性。相比传统的气象监测站,手持式气象监测设备体积小巧、重量轻,用户可以轻松…

聊一聊 Node.js V22.5 有啥重要更新

大家好,今天我们来聊聊 Node.js 最新发布的 V22.5 版本。作为一名开发者,每次看到新的版本更新,总是让人期待不已。V22.5 中新增了许多强大且实用的功能,让我们的开发工作更加高效便捷。在这篇文章中,我们将重点讨论以…

压测实操--kafka-consumer压测方案

作者:九月 环境信息: 操作系统centos7.9,kafka版本为hdp集群中的2.0版本。 Consumer相关参数 使用Kafka自带的kafka-consumer-perf-test.sh脚本进行压测,该脚本参数为: thread:测试时的单机线程数&…

心率血氧传感器 - 从零开始认识各种传感器【第十三期】

1、什么是心率血氧传感器 心率传感器是一种用于测量人体心跳频率的设备或传感器。由于脉搏或者心率是生命体征的重要参数之一,所以心率测量是目前可穿戴产品必备的一个测量和健康监控功能。 而血氧传感器是一种用于测量人体血液中氧气饱和度的设备或传感器。血氧饱…

c# 端口监控 Helper 以及写一个端口监控工具

c# 端口监控 Helper 以及写一个端口监控工具 介绍核心代码:工具完整编码:1、编写界面2、打开定时控件的属性设置。3、编写定时控件的 Tick 事件结果(运行效果) 介绍 由于最近做上架比较多,会经常来确保服务器的服务&a…

分享从零开始学习网络设备配置--任务6.1 实现计算机的安全接入

项目描述 随着网络技术的发展和应用范围的不断扩大,网络已经成为人们日常生活中必不可少的一部分。园区网作为给终端用户提供网络接入和基础服务的应用环境,其存在的网络安全隐患不断显现出来,如非人为的或自然力造成的故障、事故&#xff1b…

第八讲:Sysmac Studio控制器设置

控制器设置 一、控制器设定-操作设置 1、启动模式(运行模式/编程模式) 控制器上电后,希望程序运行还是不运行。如果说希望程序运行,那么就选择运行模式。如果说希望上电后程序不运行就选择编程模式。 通常情况下选运行模式可能会比较多一些。 2、SD内存卡设置 当控制…

科研绘图系列:R语言和弦图 (Chord diagram)

介绍 和弦图(Chord Diagram)是一种用于展示多个实体之间相互关系的数据可视化方法。它通常用于表示网络或系统中不同节点(实体)之间的连接强度或流量。和弦图由一个圆形布局组成,每个节点在圆周上占据一个扇形区域,节点之间的连接通过圆内的线条(和弦)来表示。 特点:…

获取本地时间(Linux下,C语言)

一、函数 #include <time.h> time_t time(time_t *tloc);函数功能&#xff1a;获取本机时间&#xff08;以秒数存储&#xff0c;从1970年1月1日0:0:0开始到现在&#xff09;。返回值&#xff1a;获得的秒数&#xff0c;如果形参非空&#xff0c;返回值也可以通过传址调用…

判断字符串,数组方法

判断字符串方法 在JavaScript中&#xff0c;可以使用typeof操作符来判断一个变量是否为字符串。 function isString(value) {return typeof value string; } 判断数组 在JavaScript中&#xff0c;typeof操作符并不足以准确判断一个变量是否为数组&#xff0c;因为typeof会…

Soul App创始人张璐团队参与公益活动,帮助年轻人正视并管理情绪需求

最近,“脆皮年轻人”在社交平台上持续走红。该词指年轻人常因别人一些无意的动作而导致身体或心理创伤,反映出“Z世代”年轻人面临着心理健康挑战。在此背景下,Soul APP创始人张璐团队携手上海市精神卫生中心(宛平南路600号),共同发起了一场别开生面的青年心理健康公益活动,旨在…

JDBC操作MySQL数据

一准备、 1、首先在IDEA中导入导入包&#xff1a;mysql-connector-java-8.0.23 2、写初始化语句 &#xff08;1&#xff09;在目录下找到driver类 &#xff08;2&#xff09;在JDBCUtil函数中把驱动器的类路径改掉 ①打开driver类 ②按住类名 Driver用快捷键 CtrlAltshiftC …

学懂C语言(十八):C语言中数组及其应用

目录 一、数组的概念 二、数组的声明、初始化及访问 1、声明 2、初始化 3、访问数组元素 三、数组的应用 1. 存储和处理数据 2. 字符串处理 3. 多维数组 4. 函数参数 5、注意事项 一、数组的概念 C语言中的数组是一种数据结构&#xff0c;用于存储一…

开源邮箱套件介绍系列1:SOGo

项目网站&#xff1a;SOGo | Free Open Source Webmail 提示&#xff1a;如下内容大部分来自官方网站&#xff0c;通过AI智能翻译而来。 1. SOGo功能概述 SOGo提供了多种访问日历和消息数据的方式。您的用户可以使用网页浏览器、Microsoft Outlook、Mozilla Thunderbird、Ap…

连接hive库增加相关包

连接hive库增加相关包 例如&#xff1a;java.lang.NoClassDefFoundError: com/ctc/wstx/io/InputBootstrapper org.apache.hadoop.hive.common.auth.HiveAuthUtils java.lang.NoClassDefFoundError: org/codehaus/stax2/XMLInputFactory2

Windows系统上Git详细图文安装及使用教程

Git 是一种高效、分布式的版本控制系统&#xff0c;用于代码的跟踪、分支管理和协同工作&#xff0c;支持快速提交、合并和回滚操作。它是开发者工具箱中必不可少的工具之一&#xff0c;广泛应用于软件开发和其他需要版本控制的领域。 1. Git的安装 1.1 Git下载 可以通过以下…

ESXi 虚拟机迁移,版本不兼容问题处理

背景描述 已知要被迁移的虚拟机的兼容性版本较高&#xff0c;如下图所示&#xff1a; 这个兼容性版本&#xff0c;是在创建虚拟机的时候&#xff0c;我们手工选择的&#xff0c;如下图所示&#xff1a; 当我们需要将一个虚拟机迁移到另外一个 ESXi 主机时&#xff0c;能否正常…

【计算机网络】三次握手、四次挥手

问&#xff1a;三次握手 四次挥手 TCP 连接过程是 3 次握手&#xff0c;终止过程是 4 次挥手 3次握手 第一步&#xff1a;客户端向服务器发送一个带有 SYN&#xff08;同步&#xff09;标志的包&#xff0c;指示客户端要建立连接。 第二步&#xff1a;服务器收到客户端的请求…

Shiro安全框架(上)

目录 第一章 权限概述 1、什么是权限 2、身份认证概念-Authentication 【1】什么是认证 【2】对象 2、用户授权概念-Authorization 【1】什么是授权 【2】授权流程 第二章 Shiro概述 1、Shiro简介 【1】什么是Shiro? 【2】Shiro 的特点 2、核心组件 第三章 Shiro…

【CSharp】VisualStudio2019进行Windows窗体编程时关于AnyCPU的说明

【CSharp】VisualStudio2019进行Windows窗体编程时关于AnyCPU的说明 1.背景2.说明3.修改1.背景 IDE:Visual Studio 2019 通过VS2019编写windows窗体应用程序时,在VS2019界面可以看到Any CPU,如下: 2.说明 在Visual Studio 2019中进行Windows窗体编程时, AnyCPU是一个平…