当前位置:网站首页>Mac mysql数据库基本操作
Mac mysql数据库基本操作
2022-06-29 08:38:00 【菜鸟小白瓣大神】
1、启动、重启、停止、查看 MySQL状态
sudo /usr/local/mysql/support-files/mysql.server start
sudo /usr/local/mysql/support-files/mysql.server stop
sudo /usr/local/mysql/support-files/mysql.server restart
sudo /usr/local/mysql/support-files/mysql.server status
2、重置密码
长时间不用,忘记密码是经常的事。。。此时需要重置密码。
mysql -u root -p
3.进入数据库
/usr/local/MySQL/bin/mysql -u root -p
4.查询数据库
show databases;
二、连接远程数据库并进入命令行:
假设远程主机的IP为:ip地址,用户名为root,密码为123456
1、打开终端,输入如下命令:
mysql -h ip地址 -u root -p 123456
2、输入密码:
界面提示输入密码:
Enter password:
若为初次使用该数据库,则默认密码为空,直接回车即可进入mysql命令行;
若已设置密码,则输入密码后,回车,即可进入mysql命令行。
三、退出命令:exit,再回车即可退出mysql命令行。
四:
1、创建一个名字为NickYang数据库 create database NickYang character set utf8;
2、修改数据库编码:alter database NickYang character set utf8;
3、查看数据库是否创建成功:show databases;
4、进入数据库:use NickYang;
5、创建表并为表分配一个主键:create table yang(id int primary key);
6、查看表是否创建成功:show tables;
7、查看表结构:desc 表名;
8、增加字段:alter table 表名 add 字段名 数据类型[位置];
alter table yang add name varchar(255) after id;
9、删除字段:alter table 表名 drop 字段名;
alter table yang drop name;
10、新增数据:insert into 表名(字段名) values(值)
insert into yang(id,name) values(1,'name');
11、删除数据:delete from 表名 [where 条件];
delete from yang [where id = 1]
12、修改数据:update 表名 set 字段 = 值[where 条件]
update yang set name = 'yang' where id = 1;
13、查找数据:select * from 表名 [where 条件];
select * from yang [where id = 1];
边栏推荐
- Member inner class, static inner class, local inner class
- cmd进入虚拟机
- Lffd: a lightweight fast face detector for edge detection
- Pat (basic level) practice (Chinese) 1003 I want to pass! (20 points) C language implementation
- 微信小程序跳转公众号图文内容
- 微信小程序wx.navigateBack返回上一页携带参数
- Which securities company is good for opening a mobile account? Is it safe to open an account online?
- 第十二章 信号(二)- 生产者消费者示例
- [to.Net] C data model, from Entity Framework core to LINQ
- UE4 在4.20-23版本安裝Datasmith插件
猜你喜欢

Write down some written test questions

UE4 蓝图修改Array 中Get a copy 为 reference

What is hyperfusion? What is the difference with traditional architecture

Share code snippets of wechat applet

UE4 在4.20-23版本安装Datasmith插件

微信小程序用户拒绝授权地理位置信息再次调起授权窗口

Handwritten virtualdom

Wechat applet sub components transfer values to the page (communication between parent and child components) with source code

UE4 动画重定向

The former security director of Uber faced fraud allegations and concealed the data leakage event
随机推荐
What is the difference between hyperconverged architecture and traditional architecture?
Training kernel switching using GPU
数据处理时代,数据质量建设才是企业的生存之道
YOLO Nano:一种高度紧凑的只看一次的卷积神经网络用于目标检测
Detecting and counting tiny faces
Pytorch summary learning series - data manipulation
keras转tf.keras中VGG19 input_shape
SSD Improvement cfenet
Member inner class, static inner class, local inner class
H5 soft keyboard problem
Uni app gets the route URL of the current page
使用GPU训练kernel切换
Simple use of promise method
深卷积神经网络时代的目标检测研究进展
ISO16000-9建筑产品和家具中挥发性有机物的测试
Augfpn: improved multiscale feature learning for target detection
promise方法的简单使用
Record the field name dynamically modified by SetData of wechat applet
UE4 在viewport视口中显示3D可编辑点
查找字符串中重复次数最多的元素