首页 > 数据库 >Ubuntu安装MySQL数据库

Ubuntu安装MySQL数据库

时间:2023-12-08 11:34:12浏览次数:34  
标签:数据库 Ubuntu Server mysql MySQL cby root

Ubuntu安装MySQL数据库

介绍

MySQL 的定义
MySQL 是一种开源关系型数据库管理系统。与其他关系型数据库一样,MySQL 将数据存储在由行和列组成的表中。用户可以使用结构化查询语言(通常称为 SQL)定义、操作、控制和查询数据。由于 MySQL 是开源的,因此它的大量功能是在超过 25 年与用户密切合作的过程中开发出来的。

MySQL 软件是开源的
MySQL 是开源的,这意味着按照 GNU 通用公共许可条款,该工具可以免费使用。这也意味着,任何人都可以根据自己的使用需求自由修改软件的源代码。这使得 MySQL 分支为其他数据库变体(例如 MariaDB 和 Percona Server for MySQL)。MySQL 也可以通过其他许可用于商业用途。

关系型数据库
MySQL 所属的数据库类别称为关系型数据库管理系统 (RDBMS)。关系型数据库是信息的集合,它以预定义的关系组织数据,数据存储在一个或多个由列和行构成的表(或称“关系”)中,用户可以轻松查看和理解不同数据结构之间的关系。关系是不同表之间的逻辑连接,根据这些表之间的交互建立。

下载

下载地址https://dev.mysql.com/downloads/在此页面中,需要选择你要安装的版本类型,我这里是Ubuntu系统所以选择 MySQL APT Repository,若你使用CentOS那么就使用MySQL Yum Repository

#下载地址
# https://dev.mysql.com/downloads/

# 选择你要安装的版本类型,我这里是Ubuntu系统所以选择 MySQL APT Repository,若你使用CentOS那么就使用MySQL Yum Repository

apt install https://dev.mysql.com/get/mysql-apt-config_0.8.28-1_all.deb

# 安装MySQL-Server
apt install mysql-community-server

# 查看服务是否正常
root@cby:~# systemctl status mysql
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2023-12-06 15:35:30 CST; 22min ago
       Docs: man:mysqld(8)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
   Main PID: 9786 (mysqld)
     Status: "Server is operational"
      Tasks: 39 (limit: 3943)
     Memory: 369.3M
        CPU: 3.989s
     CGroup: /system.slice/mysql.service
             └─9786 /usr/sbin/mysqld

Dec 06 15:35:29 cby systemd[1]: Starting MySQL Community Server...
Dec 06 15:35:30 cby systemd[1]: Started MySQL Community Server.
root@cby:~# 

开启外部访问

# 登录数据库
root@cby:~# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.35 MySQL Community Server - GPL

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>


# 查看默认库
mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

# 选择使用mysql库
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> 
mysql> 

# 查询用户表
mysql> select host, user, authentication_string, plugin from user;
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
| host      | user             | authentication_string                                                  | plugin                |
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
| localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | mysql.session    | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | mysql.sys        | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| localhost | root             | $A$005$yWgZ hKW4{ege
                                                     W/5pMsmD7O.Tq.KL8z9ARsM1TcL74ysSUXrqH0pWKEj5 | caching_sha2_password |
+-----------+------------------+------------------------------------------------------------------------+-----------------------+
4 rows in set (0.00 sec)

mysql> 

# 修改root的授权
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql> 
mysql> 
mysql> Grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.01 sec)
mysql> 

# 刷新权限
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> 
mysql>
mysql> ^DBye
root@cby:~# 
root@cby:~#

测试

# 使用其他主机进行登录数据库
root@cby:~# mysql -u root -p -h x.oiox.cn
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.35 MySQL Community Server - GPL

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> 
mysql> 
mysql> ^DBye
root@cby:~# 
root@cby:~# 

关于

https://www.oiox.cn/

https://www.oiox.cn/index.php/start-page.html

CSDN、GitHub、51CTO、知乎、开源中国、思否、博客园、掘金、简书、华为云、阿里云、腾讯云、哔哩哔哩、今日头条、新浪微博、个人博客

全网可搜《小陈运维》

文章主要发布于微信公众号

标签:数据库,Ubuntu,Server,mysql,MySQL,cby,root
From: https://www.cnblogs.com/chenby/p/17884812.html

相关文章

  • Ubuntu安装typecho博客
    Ubuntu安装typecho博客简介名称的来历Typecho是由type和echo两个词合成的,来自于开发团队的头脑风暴。Type,有打字的意思,博客这个东西,正是一个让我们通过打字,在网络上表达自己的平台。Echo,意思是回声、反馈、共鸣,也是PHP里最常见、最重要的函数,相信大部分PHP爱好者都是从e......
  • 数据库
    本单元目标一、为什么要学习数据库二、数据库的相关概念 DBMS、DB、SQL三、数据库存储数据的特点四、初始MySQL MySQL产品的介绍 MySQL产品的安装★ MySQL服务的启动和停止★ MySQL服务的登录和退出★ MySQL的常见命令......
  • Idea2023.2连接数据库
    一、Idea实现连接MySQL数据库注意:在Jetbrains全家桶都适用。1.1.在Idea里打开1.2.设置基本信息1.3.测试注意:测试不通过查看问题二、Idea自带可视化工具操作三、问题3.1问题1简介:丢失MySQL驱动注意:Pycharm也是Jetbrains全家桶之一方式二解决下载驱动:https:......
  • mongdb数据库下载与安装
    mongdb数据库下载与安装前言:不支持WindowsXP系统最好不要安装最新版本下载以及安装:mongdb安装https://www.mongodb.com/try/download/community傻瓜式安装,这里不过多叙述,只需注意下述几点!记得去高级系统设置查看是否配置,我的配置路径为D:\MongoDB\Server\4.4\bin......
  • MySQL数据表的CURD
    一、数据表的CURD1.create数据创建一个员工表,新建employee表并向表中添加一些记录:创建数据表:createtableemployee(idint,namevarchar(20),sexint,birthdaydate,salarydouble,entry_datedate,resumetext);向数据表中插入数据:insertintoemployeevalues(......
  • VMware17 ubuntu18.04.5安装好后无法访问win11共享文件夹的问题
    1在关闭虚拟机的情况下,点击虚拟机设置,CD/DVD设置使用ISO镜像文件,并设置好镜像路径。2启动虚拟机,此时重新安装VMwaretools按钮变成有效状态,点击该按钮,如果虚拟机进入系统后,该按钮会变成无效状态。3等待虚拟机自动下载VMwaretools,下载后在桌面可以看到VMwaretoolsDVD光盘,......
  • MySQL服务器8核32G max_connections设置为10000的情况,springboot里面的Druid参数配置
    MySQL服务器8核32Gmax_connections设置为10000的情况,springboot里面的Druid参数配置多少合适啊,MySQL服务器8核32G,max_connections设置为10000,确实是相当大的一个配置啊。对于Druid的参数配置,得看你系统的具体情况。一般来说,你可以考虑以下几个参数:initialSize:连接池的初始大小,你......
  • 【环境配置记录】ubuntu用samba共享文件夹给windows
    中文社区真的不太行,英文社区资源丰富很多转载https://askubuntu.com/questions/1462387/trying-to-samba-share-a-folder-always-gives-errors的答案 Pleaseseethefollowinginstallationguideline.Itcaneffectivelysolvetheoutstandingissueof'netusershare'r......
  • Ubuntu下MPICH的安装与配置
    原创直达链接一、MPICH的下载与安装MPI安装文件下载地址:博客下载地址或官网地址可以下载3.4.2版本的,本文就是3.4.2版本1.解压:sudotar-zxvfmpich-3.4.2.tar.gz2.进入mpich-3.4.2文件夹:cdmpich-3.4.23.进行软件配置与检查:先用apt安装gcc,g++sudoaptinstallgcc......
  • mysql的约束M
    数据表的约束约束的目的是保证数据库中数据的完整性和一致性常见的约束有主键约束(primarykey)外键约束(foreignkey)非空约束(notnull)唯一约束(unique)默认约束(default)1:primarykey约束理解:primarykey可以有一个字段或者多个字段组成,要求:主键字段的数据唯一,并且不能为空......