当前位置:网站首页>MySQL笔记1_数据库
MySQL笔记1_数据库
2022-04-23 06:07:00 【小叶很笨呐!】
Dos登录
mysql -h服务器地址 -u用户名 -p密码
mysql -hlocalhost -uroot -proot
数据库
1、查询所有的数据库
show databases
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
2、创建数据库("[]"代表可有可无)
create database <数据库名称> [character set 编码集]
mysql> create database personal_inf;
Query OK, 1 row affected (0.00 sec)
3、删除数据库
drop database [if exists] <数据库名>
if exists:用于防止当前数据库不存在时发生错误
4、查看当前数据库的编码
show create database <数据库名称>
mysql> show create database personal_info;
+---------------+--------------------------------------------------------------------------+
| Database | Create Database |
+---------------+--------------------------------------------------------------------------+
| personal_info | CREATE DATABASE `personal_info` /*!40100 DEFAULT CHARACTER SET latin1 */ |
+---------------+--------------------------------------------------------------------------+
1 row in set (0.00 sec)
5、修改单个数据库的编码格式
alter database 数据库名称 character set utf8
6、修改数据名称
方法1:CSDN,数据迁移
方法2:推出mysql,然后,到这个数据存储的位置,找到文件名并修改
方法3:rename database 旧的名称 to 新的名称
(高版本及以上用不了,有丢失数据的风险,不安全)
7、使用数据库
use <数据库名称>
mysql> use personal_info
Database changed
8、查看当前使用的数据库
select database();
mysql> select database ();
+---------------+
| database () |
+---------------+
| personal_info |
+---------------+
1 row in set (0.00 sec)
版权声明
本文为[小叶很笨呐!]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_50957373/article/details/120898713
边栏推荐
猜你喜欢

Using Prom label proxy to implement label based multi tenant reading of Prometheus thanos

iTOP4412 HDMI显示(4.4.4_r1)

实习做了啥

接口幂等性问题

Problems related to Prometheus cortex using block storage

Static interface method calls are not supported at language level ‘5‘ 异常解决

Prometheus cortex Architecture Overview (horizontally scalable, highly available, multi tenant, long-term storage)

开篇:双指针仪表盘的识别

Winter combat camp hands-on combat - MySQL database rapid deployment practice lead mouse cloud Xiaobao

Apache SeaTunnel 2.1.0部署及踩坑
随机推荐
組件化學習
oracle视图相关
Exception record-9
this.getOptions is not a function
Exception record-6
Research on alertmanager repeated / missing alarm phenomenon and two key parameters_ Wait and group_ Interpretation of interval
How does VirtualBox modify the IP network segment assigned to the virtual machine in the "network address translation (NAT)" network mode
Chaos帶你快速上手混沌工程
pycharm Install packages failed
组件化学习(3)ARouter中的Path和Group注解
oracle清除sql的缓存
iTOP4412 HDMI显示(4.0.3_r1)
Itop4412 kernel restarts repeatedly
Abnormal record-16
iTOP4412无法显示开机动画(4.0.3_r1)
Abnormal record-19
oracle 修改默认临时表空间
Abnormal record-12
三种实现ImageView以自身中心为原点旋转的方法
Information:2021/9/29 10:01 - Build completed with 1 error and 0 warnings in 11s 30ms Error异常处理