以上就是给各位分享如何在Ubuntu22.04上安装MySQL数据库?,同时本文还将给你拓展installnginxonubuntuinstallubuntuusbinstallubuntu14.04
以上就是给各位分享如何在 Ubuntu 22.04 上安装 MySQL 数据库 ?,同时本文还将给你拓展install nginx on ubuntu install ubuntu usb install ubuntu 14.04 ubuntu install jd、企业级 mysql 数据库 [mariadb]—————— 了解数据库、了解 mariadb 与 mysql 的关系,安装一个安全的 mariadb 数据库、哨兵/Snuba/Clickhouse [1000] 数据库::异常 [271] 数据库::异常 [62] 数据库::异常、在 Ubuntu 12.04 上安装 Ubuntu Tweak 0.7.0等相关知识,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:- 如何在 Ubuntu 22.04 上安装 MySQL 数据库 ?
- install nginx on ubuntu install ubuntu usb install ubuntu 14.04 ubuntu install jd
- 企业级 mysql 数据库 [mariadb]—————— 了解数据库、了解 mariadb 与 mysql 的关系,安装一个安全的 mariadb 数据库
- 哨兵/Snuba/Clickhouse [1000] 数据库::异常 [271] 数据库::异常 [62] 数据库::异常
- 在 Ubuntu 12.04 上安装 Ubuntu Tweak 0.7.0
如何在 Ubuntu 22.04 上安装 MySQL 数据库 ?
MySQL 是一种流行的开源关系数据库管理系统(RDBMS),它使用 SQL 语法来执行数据库操作,如 CRUD(创建、读取、更新和删除),管理用户和权限。
MySQL 数据库是一个高性能数据库,在 LAMP 组合中扮演着不可或缺的角色,它存储网站数据。它与 PHP 无缝配合,在 web 开发中很受欢迎。MySQL 还具有高度的可定制性,支持多达数百万条记录的大型数据库,它还提供数据复制和冗余,以提供容错能力。
必备条件
- 预装 Ubuntu 22.04 系统
- 具有管理员访问权限的 Sudo 用户
可靠的互联网连接
(1) 更新 APT 软件包索引
首先,登录到您的服务器实例并更新本地 APT 包索引。
$ sudo apt update
(2) 安装 MySQL
MySQL 服务器包在 Ubuntu 的存储库中免费提供。在编写本指南时,最新版本是 MySQL server 8.0,并且已经托管在存储库中。
$ sudo apt install mysql-server -y
安装完成后,MySQL 守护进程就会自动启动并在后台安静运行,通过下命令来确认
$ sudo systemctl status mysql
也可以通过以下命令确认
$ systemctl is-active mysql
您可以将 MySQL 设置为随系统自动启动,如图所示。
$ sudo systemctl enable mysql
(3) MySQL Server 安装安全设置
默认的 MySQL 设置是不安全的,特别是如果您打算在生产中使用数据库服务器。
MySQL 安装提供了一个安全脚本,用于解决不太安全的默认选项,请运行以下命令:
$ sudo mysql_secure_installation
默认情况下,MySQL 使用 auth_socket 进行身份验证。这是一种无密码身份验证,使用 auth_socket 插件,用户可以使用其用户帐户凭据登录 MySQL 并对其进行身份验证。
如果您希望使用密码验证,请按 CTRL+C 取消操作并访问 MySQL 终端
$ sudo mysql
接下来,运行 ALTER USER 命令将 root 用户的身份验证方法修改为密码验证,如图所示。
ALTER USER ''root''@''localhost'' IDENTIFIED WITH mysql_native_password BY ''mypassword'';
然后,退出 MySQL 终端
FLUSH PRIVILEGES
EXIT
再次运行脚本,提供 root 密码,然后按 ENTER。接下来,您可以选择更改 root 用户的密码或提供新密码。在我们的情况下,我们不修改密码,因此,我们将按 N。
对于其余提示,请按 Y 以保护数据库服务器的安全,执行以下操作来确保数据库安全性。
- 删除任何匿名用户
- 不允许 root 用户远程登录
- 删除测试数据库及其访问权限
- 保存通过重新加载特权表所做的更改
(4) 创建 MySQL 管理用户
默认情况下,MySQL 会在安装期间创建一个默认的根用户来管理数据库。用户拥有完全权限,因此可以对所有数据库、表、用户等进行绝对控制。
建议为运行管理任务创建一个单独的数据库用户,再次以 root 用户身份登录 MySQL 数据库服务器。
$ sudo mysql -u root -p
创建数据库用户
CREATE USER ''linuxtechi''@''localhost'' IDENTIFIED BY ''password'';
然后将所有权限授予用户,. 表示数据库服务器中的所有数据库。
GRANT ALL PRIVILEGES ON *.* TO ''linuxtechi''@''localhost'' WITH GRANT OPTION;
接下来,刷新PRIVILEGES
FLUSH PRIVILEGES
退出 MySQL 终端
EXIT
以管理用户身份登录
$ mysql -u linuxtechi -p
我的开源项目
- course-tencent-cloud(酷瓜云课堂 - gitee仓库)
- course-tencent-cloud(酷瓜云课堂 - github仓库)
install nginx on ubuntu install ubuntu usb install ubuntu 14.04 ubuntu install jd
企业级 mysql 数据库 [mariadb]—————— 了解数据库、了解 mariadb 与 mysql 的关系,安装一个安全的 mariadb 数据库
文章目录
- 1. 数据库的介绍
-
- 1.1 数据是什么?
- 1.2 帐号密码如何存储?
- 1.3 什么是数据库?
- 1.4 什么是 mariadb 数据库?
- 2. 安装安全的 mariadb。
-
- 2.1 安装
- 2.2 安全初始化
- 2.3 关闭网络端口
1. 数据库的介绍
1.1 数据是什么?
密码账户、图片、视频、数字,链接都是人类可以解除的数据。
机器语言二进制语言是计算机了解的数据。
1.2 帐号密码如何存储?
如果将一个网站的文档存在一个普通文档中:可能被误删除,文件也不安全;大数据量的时候可能存储限制;查询用户也很麻烦。
所以我们使用数据库管理系统(DBMS)。
关系型数据库(RDBMS):比较适合于,安全级别要求高的数据以及关系较复杂的数据:Oracle,Mysql
非关系型数据库:适合于高性能存取数据,一般是配合 RDBMS 进行使用的,针对大数据处理分析,分布式架构更加擅长:MongoDB(文档型)、Redis
1.3 什么是数据库?
数据库,简而言之可视为电子化的文件柜 —— 存储电子文件的处所,用户可以对文件中的数据进行新增、截取、更新、删除等操作。
所谓 “数据库” 是以一定方式储存在一起、能与多个用户共享、具有尽可能小的冗余度、与应用程序彼此独立的数据集合
数据对一个企业是非常重要的,其实就相当于我们每个人的信息就是自己的属性,并且把它记录在一个文件里面
多张表格组成一个数据库,tab (表)---->db (库)-----> 数据库软件
1.4 什么是 mariadb 数据库?
MariaDB 是 MySQL 源代码的一个分支。
MariaDB 由 MySQL 的创始人 Michael Widenius 主导开发,他早前曾以 10 亿美元的价格,将自己创建的公司 MySQL AB 卖给了 SUN。此后,随着 SUN 被甲骨文收购,MySQL 的所有权也落入 Oracle 的手中,MariaDB 名称来自 Michael Widenius 的女儿 Maria 的名字。
MariaDB 不仅仅是 Mysql 的一个替代品,MariaDB 包括的一些新特性使它优于 MySQL。
MariaDB 跟 MySQL 在绝大多数方面是兼容的。在存储引擎方面,使用 XtraDB(英语:XtraDB)来代替 MySQL 的 InnoDB。
2. 安装安全的 mariadb。
2.1 安装
实验准备:
- 一台配置好 yum 仓库的 linux 虚拟机。
1)直接进行 yum 安装:
[root@mariadb ~]# yum search mariadb # 查询所有mariadb有关的安装包
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-
: manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
============================= N/S matched: mariadb =============================
mariadb-bench.x86_64 : MariaDB benchmark scripts and data
mariadb-devel.i686 : Files for development of MariaDB/MySQL applications
mariadb-devel.x86_64 : Files for development of MariaDB/MySQL applications
mariadb-libs.i686 : The shared libraries required for MariaDB/MySQL clients
mariadb-libs.x86_64 : The shared libraries required for MariaDB/MySQL clients
mariadb-server.x86_64 : The MariaDB server and related files
mariadb.x86_64 : A community developed branch of MySQL
mariadb-test.x86_64 : The test suite distributed with MariaD
Name and summary matches only, use "search all" for everything.
[root@mariadb ~]# yum install mariadb-server -y #安装mariadb服务
Installed:
mariadb-server.x86_64 1:5.5.52-1.el7
Dependency Installed:
mariadb.x86_64 1:5.5.52-1.el7 perl-DBD-MySQL.x86_64 0:4.023-5.el7
Complete!
2)开启 mariadb 服务:
[root@mariadb ~]# systemctl start mariadb.service
3)输入 mysql 可以直接进入数据库查看:
[root@mariadb ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.52-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type ''help;'' or ''\h'' for help. Type ''\c'' to clear the current input statement.
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
直接查看数据库没有密码就可以进入,这是非常不安全的。
2.2 安全初始化
1)数据库起始状态设定信息是不安全的,需要做以下设定:
[root@mariadb ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we''ll need the current password for the root user. If you''ve just installed MariaDB, and
you haven''t set the root password yet, the password will be blank, so you should just press enter here.''
Enter current password for root (enter for none): # 之前没有密码直接回车
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y # 要设定密码
New password: # 新的密码
Re-enter new password: # 重复密码
Password updated successfully! # 密码更新成功
Reloading privilege tables..
... Success!
Remove anonymous users? [Y/n] y # 进制匿名用户远程登录
... Success!
Normally, root should only be allowed to connect from ''localhost''. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y # 进制远程登录root
... Success!
By default, MariaDB 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.
Remove test database and access to it? [Y/n] y # 删除测试数据库,并进入数据库
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y # 重新加载表格
... Success!
Cleaning up...
All done! If you''ve completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
2)直接输入 mysql 无法登录:
[root@mariadb ~]# mysql
ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using password: NO)
3)输入密码进行测试登录:
[root@mariadb ~]# mysql -uroot -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 5.5.52-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type ''help;'' or ''\h'' for help. Type ''\c'' to clear the current input statement.
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
MariaDB [(none)]>[root@mariadb ~]# mysql -uroot -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 5.5.52-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type ''help;'' or ''\h'' for help. Type ''\c'' to clear the current input statement.
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
MariaDB [(none)]>
2.3 关闭网络端口
默认情况下,数据库的网络端口是打开的,为了安全需要关闭此接口:
1)查看数据库的网络端口是否开启:
[root@mariadb ~]# netstat -antlupe | grep mysql
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 27 33752 4156/mysqld
2)关闭网络端口(开着很不安全,别人可以通过网络端口看到我的数据库)
[root@mariadb ~]# vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
skip-networking=1
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
3)重启 mariadb,查看网络端口是否还是开启:
[root@mariadb ~]# systemctl restart mariadb.service
[root@mariadb ~]# netstat -antlupe | grep mysql
[root@mariadb ~]#
4)现在只有通过本地用户可以登录:
[root@mariadb ~]# mysql -uroot -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.52-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type ''help;'' or ''\h'' for help. Type ''\c'' to clear the current input statement.
MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
哨兵/Snuba/Clickhouse [1000] 数据库::异常 [271] 数据库::异常 [62] 数据库::异常
如何解决哨兵/Snuba/Clickhouse [1000] 数据库::异常 [271] 数据库::异常 [62] 数据库::异常
将 Sentry 数据迁移到新的 K8s 集群后,Sentry 问题出现以下错误:
[1000] DB::Exception: Exception: Too large string size.
[62] DB::Exception: Empty query: while receiving packet from sentry-clickhouse-0.sentry-clickhouse-headless.infra.svc.cluster.local:9000: While executing Remote.
[271] DB::Exception: Data compressed with different methods,given method byte 0xf0,prevIoUs method byte 0x82: while receiving packet from sentry-clickhouse-0.sentry-clickhouse-headless.infra.svc.cluster.local:9000: While executing Remote.
哨兵旧版本:20.12.1
哨兵新版本:21.5.1
K8s 旧集群版本:
Client Version: version.Info{Major:"1",Minor:"19",GitVersion:"v1.19.4",GitCommit:"d360454c9bcd1634cf4cc52d1867af5491dc9c5f",GitTreeState:"clean",BuildDate:"2020-11-11T13:17:17Z",GoVersion:"go1.15.2",Compiler:"gc",Platform:"linux/amd64"}
Server Version: version.Info{Major:"1",GitVersion:"v1.19.7",GitCommit:"1dd5338295409edcfff11505e7bb246f0d325d15",BuildDate:"2021-01-13T13:15:20Z",GoVersion:"go1.15.5",Platform:"linux/amd64"}
K8s 新集群版本:
Client Version: version.Info{Major:"1",Minor:"21",GitVersion:"v1.21.0",GitCommit:"cb303e613a121a29364f75cc67d3d580833a7479",BuildDate:"2021-04-08T16:31:21Z",GoVersion:"go1.16.1",BuildDate:"2021-04-08T16:25:06Z",Platform:"linux/amd64"}
Postgress DB 是通过 pg_dump
传输的。
Clickhouse 数据库是通过 clickhouse-backup
传输的。
也许有人遇到过这样的问题? 我将非常感谢您的帮助。谢谢!
在 Ubuntu 12.04 上安装 Ubuntu Tweak 0.7.0
Ubuntu Tweak 是国人 @图拉鼎 开发的一款专门为Ubuntu准备的配置、调整工具。不论您是新手还是老手,都将从这个工具中获取帮助。
Ubuntu Tweak 刚刚发布了 0.7.0 版本,详细改进内容请看这里。
在 Ubuntu 12.04 上的安装方法:
sudo add-apt-repository ppa:tualatrix/ppa sudo apt-get update sudo apt-get install ubuntu-tweak
屏幕截图:
今天关于如何在 Ubuntu 22.04 上安装 MySQL 数据库 ?的分享就到这里,希望大家有所收获,若想了解更多关于install nginx on ubuntu install ubuntu usb install ubuntu 14.04 ubuntu install jd、企业级 mysql 数据库 [mariadb]—————— 了解数据库、了解 mariadb 与 mysql 的关系,安装一个安全的 mariadb 数据库、哨兵/Snuba/Clickhouse [1000] 数据库::异常 [271] 数据库::异常 [62] 数据库::异常、在 Ubuntu 12.04 上安装 Ubuntu Tweak 0.7.0等相关知识,可以在本站进行查询。
本文标签: