当前位置:网站首页>Ubuntu及Mysql快速入门教程
Ubuntu及Mysql快速入门教程
2022-07-27 09:59:00 【项羽-韩】
写在前面,众所周知,云服务器在相当普及的时代,创建一个属于自己的虚拟网络空间,个人对此充满了期待。
本文讲解了在已有 云服务器 的前提下,介绍创建一套完整的数据库及对用户管理的认知,这些都是在大型公司无法接触到的内容。之后,会完整的介绍如何使用springboot搭建项目,及设计、研发、测试并发布一款app或小程序,了解项目管理各环节的流程及衔接事项。
鲜花少许,直入正题:
一、安装mysql
sudo apt update
更新apt索引;
sudo apt install mysql-server
安装mysql数据库,一路【yes】下去,无设置密码选项;
sudo mysql_secure_installation
运行安全脚本,密码检测插件、设置密码;
mysql -V
显示安装mysql的信息,例如:版本、系统;
二、修改 root 用户的登陆方式
sudo mysql
进入mysql数据库;
SELECT user,authentication_string,plugin,host FROM mysql.user;
展示所有用户的认证方式【两类:密码认证、auth_socket插件认证】;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的数据库密码';
为root用户设置密码;
FLUSH PRIVILEGES;
生效;
SELECT user,authentication_string,plugin,host FROM mysql.user;
检查是否生效;
exit;
退出;
sudo mysql;
报错,因为已经修改为密码认证登陆;
mysql -u root -p
密码认证登陆,输入密码即可;
三、创建、删除数据库
mysql -u root -p;
使用 root 角色用户登陆数据库;
show databases;
显示数据库列表;
create database srping;
创建名为 srping 的数据库;
create database test;
创建名为 test 的数据库;
show databases;
显示数据库列表,可看到已经创建了以上两个数据库;
drop database test;
删除名为 test 的数据库;
show databases;
显示数据库列表,验证是否删除成功;
四、创建新用户,并授权权限
mysql -u root -p
输入密码,登陆数据库;
CREATE USER 'xiaochun'@'localhost' IDENTIFIED BY '你的高强度密码';
创建用户名为 xiaochun的用户,并设置密码为 【你的高强度密码】
show grants for 'xiaochun'@'localhost';
显示 spring 用户的权限,由于没有授予权限,可看到默认权限:
// GRANT USAGE ON *.* TO 'xiaochun'@'localhost'
//即 USAGE(只允许登录)
exit;
退出;
mysql -u xiaochun -p
验证是否能够登陆,输入密码,登陆数据库;
exit;
退出;
mysql -u root -p
更换为root用户;
//介绍授权命令格式: grant A on B to C
// A:用户操作权限,SELECT,INSERT,UPDATE,privileges,all ,USAGE(只允许登录)
// B:授权对象,*.* 代表所有数据库所有表;也可以指定数据库、数据库下的表
// C:用户名
grant all privileges on spring.* to 'xiaochun'@'localhost';
给与用户 【xiaochun】 赋予数据库名为【 spring】所有操作权限;
flush privileges;
刷新权限表;
show grants for 'xiaochun'@'localhost';
查看是否授权;
exit;
退出;
mysql -u xiaochun -p
更换用户登陆;
show grants for 'xiaochun'@'localhost';
验证是否给与授权;
exit;
至此,所有训练项目介绍完毕,下一节课,介绍window平台下本地连接远程服务器数据库。
补充
撤销用户权限
REVOKE privilege ON databasename.tablename FROM 'username'@'host';
说明:
privilege, databasename, tablename:同授权部分
例子:
REVOKE SELECT ON *.* FROM 'pig'@'%';
设置与更改用户密码
SET PASSWORD FOR 'username'@'host' = PASSWORD('newpassword');
如果是当前登陆用户用:
SET PASSWORD = PASSWORD("newpassword");
例子:
SET PASSWORD FOR 'pig'@'%' = PASSWORD("123456");
边栏推荐
- Word2vec principle and application and article similarity (recommended system method)
- Summary of binary tree exercises
- matlab-绘制分叉与混沌分支图
- Shell operator, $((expression)) "or" $[expression], expr method, condition judgment, test condition, [condition], comparison between two integers, judgment according to file permission, judgment accor
- Xiandai 003
- 视觉SLAM十四讲笔记(一):第一讲+第二讲
- Sub query of database performance series
- Metasploit-永恒之蓝攻击
- Metaaploit-后渗透技知识
- Decision tree principle and case application - Titanic survival prediction
猜你喜欢

二叉树习题总结

Metasploit-永恒之蓝攻击

数据库性能系列之子查询

Shell process control (emphasis), if judgment, case statement, let usage, for ((initial value; loop control condition; variable change)) and for variable in value 1 value 2 value 3..., while loop

Understanding of batchnorm2d() function in pytorch

Stylegan paper notes + modify code to try 3D point cloud generation

Practice and exploration of overseas site Seata of ant group

VS2019+CUDA11.1新建项目里没有CUDA选项

直播倒计时 3 天|SOFAChannel#29 基于 P2P 的文件和镜像加速系统 Dragonfly

并发之park与unpark说明
随机推荐
Ant高级-path和fileset
FSM onehot answer record
When I went to oppo for an interview, I got numb
3D修复论文:Shape Inpainting using 3D Generative Adversarial Network and Recurrent Convolutional Networks
Food safety | are you still eating fermented rice noodles? Be careful these foods are poisonous!
Overview of PCL modules (1.6)
3D restoration paper: shape painting using 3D generative advantageous networks and recurrent revolutionary networks
Understanding and code implementation of Se (sequence and exception) module
Failure of CUDA installation nsight visual studio edition failed
NFS 服务器的搭建
LeetCode.1260. 二维网格迁移____原地暴力 / 降维+循环数组直接定位
Review of in vivo detection
3D人脸重建:Joint 3D Face Reconstruction and Dense Alignment with position Map Regression Network
直播倒计时 3 天|SOFAChannel#29 基于 P2P 的文件和镜像加速系统 Dragonfly
语音数据采集-实时语音数据可视化
Metaaploit-后渗透技知识
01_ Movie recommendation (contentbased)_ Object portrait
SE(Squeeze and Excitation)模块的理解以及代码实现
活体检测综述
LeetCode.565. 数组嵌套____暴力dfs->剪枝dfs->原地修改