mysql建库语句on报错_mysql运维必备知识点(转载至其他作者)
(1)基础笔试命令考察
1.开启MySQL服务
/etc/init.d/mysqld start
service mysqld start
systemctl start mysqld
2.检测端口是否运行
lsof -i :3306
netstat -lntup |grep 3306
3.为MySQL设置密码或者修改密码
设置密码
mysql -uroot -ppassword -e "set passowrd for root = passowrd('passowrd')"
mysqladmin -uroot passowrd "NEWPASSWORD"
更改密码
mysqladmin -uroot passowrd oldpassowrd "NEWPASSWORD"
use mysql;
update user set passowrd = PASSWORD('newpassword') where user = 'root';flush privileges;
msyql 5.7以上版本修改默认密码命令
alter user 'root'@'localhost' identified by 'root'
4.登陆MySQL数据库
mysql -uroot -ppassword
5.查看当前数据库的字符集
show create database DB_NAME;
6.查看当前数据库版本
mysql -V
mysql -uroot -ppassowrd -e "use mysql;select version();"
7.查看当前登录的用户
select user();
8.创建GBK字符集的数据库mingongge,并查看已建库完整语句
create database mingongge DEFAULT CHARSET GBK COLLATE gbk_chinese_ci;
#查看创建的库
show create database mingongge;
9.创建用户mingongge,使之可以管理数据库mingongge
grant all on mingongge.* to 'mingongge'@'localhost' identified by 'mingongge';
10.查看创建的用户mingongge拥有哪些权限
show grants for mingongge@localhost
11.查看当前数据库里有哪些用户
select user from mysql.user;
12.进入mingongge数据库
use mingongge
13.创建一innodb GBK表test,字段id int(4)和name varchar(16)
create table test (
id int(4),
name varchar(16)
)ENGINE=innodb DEFAULT CHARSET=gbk;
14.查看建表结构及表结构的SQL语句
desc test;
show create table test\G
15.插入一条数据“1,mingongge”
insert into test values('1','mingongge');
16.再批量插入2行数据 “2,民工哥”,“3,mingonggeedu”
insert into test values('2','民工哥'),('3','mingonggeedu');
17.查询名字为mingongge的记录
select * from test where name = 'mingongge';
18.把数据id等于1的名字mingongge更改为mgg
update test set name = 'mgg' where id = '1';
19.在字段name前插入age字段,类型tinyint(2)
alter table test add age tinyint(2) after id;
20.不退出数据库,完成备份mingongge数据库
system mysqldump -uroot -pMgg123.0. -B mingongge >/root/mingongge_bak.sql
21.删除test表中的所有数据,并查看
delete from test;
select * from test;
22.删除表test和mingongge数据库并查看
drop table test;
show tables;
drop database mingongge;
show databases;
23.不退出数据库恢复以上删除的数据
system mysql -uroot -pMgg123.0.
24.把库表的GBK字符集修改为UTF8
alter database mingongge default character set utf8;
alter table test default character set utf8;
25.把id列设置为主键,在Name字段上创建普通索引
alter table test add primary key(id);
create index mggindex on test(name(16));
26.在字段name后插入手机号字段(shouji),类型char(11)
alter table test add shouji char(11);
#默认就是在最后一列后面插入新增列
27.所有字段上插入2条记录(自行设定数据)
insert into test values('4','23','li','13700000001'),('5','26','zhao','13710000001');
28.在手机字段上对前8个字符创建普通索引
create index SJ on test(shouji(8));
29.查看创建的索引及索引类型等信息
show index from test;
show create table test\G
#下面的命令也可以查看索引类型
show keys from test\G
30.删除Name,shouji列的索引
drop index SJ on test;
drop index mggindex on test;
31.对Name列的前6个字符以及手机列的前8个字符组建联合索引
create index lianhe on test(name(6),shouji(8));
32.查询手机号以137开头的,名字为zhao的记录(提前插入)
select * from test where shouji like '137%' and name = 'zhao';
33.查询上述语句的执行计划(是否使用联合索引等)
explain select * from test where name = 'zhao' and shouji like '137%'\G
34.把test表的引擎改成MyISAM
alter table test engine=MyISAM;
35.收回mingongge用户的select权限
revoke select on mingongge.* from mingongge@localhost;
36.删除mingongge用户
drop user migongge@localhost;
37.删除mingongge数据库
drop database mingongge
38.使用mysqladmin关闭数据库
mysqladmin -uroot -pMgg123.0. shutdown
lsof -i :3306
39.MySQL密码丢了,请找回?
mysqld_safe --skip-grant-tables & #启动数据库服务
mysql -uroot -ppassowrd -e "use mysql;update user set passowrd = PASSWORD('newpassword') where user = 'root';flush privileges;"
mysql建库语句on报错_mysql运维必备知识点(转载至其他作者)相关推荐
- MySQL运维知识点_mysql运维必备知识点(转载至其他作者)
(1)基础笔试命令考察 1.开启MySQL服务 /etc/init.d/mysqld start service mysqld start systemctl start mysqld 2.检测端口是 ...
- mysql建库语句 最简单最常用语句
mysql建库语句 一.创建数据库 create database doc; 创建数据库doc; 二.创建用户 create user doc@'%' identified by 'mysql'; 创 ...
- mysql语句delete报错_MySQL delete语句的问题
以前遇到过几次这个问题,都觉得问题不大,所以没有记录,但是这次又遇到了,而且没有第一时间想起来,所以还是有记录下的必要 MySQL delete语句使用子查询操作同一张表的时候会抛出 DELET ...
- 查看mysql建库语句_mysql5.7-02建库、建表、查建表语句
1.库操作 1.1.创建.查询库信息 数据内容不区分大小写 root@master [mysql] >create database yanqi CHARACTER SET utf8mb4 CO ...
- mysql主从不同步不报错_MySQL主从不同步解决
1.由于binlog日志带多删除了几个后发现MySQL主从不同步 mysql> show slave status\G; Slave_IO_Running: No Slave_SQL_Runni ...
- ambari hdfs 启动报错_HDFS 运维常见问题处理
腾讯游戏CROS体系的DBA维护着多套互娱数据平台的核心HDFS集群,积累了不少维护经验. 1. 定期block全盘扫描,引起dn心跳超时而脱离集群 hdfs有一个目录扫描机制,默认6小时会全盘扫描一 ...
- mysql重装第四步报错_Mysql 8.x 安装
第一步:百度Mysql 第二步:点击DOWNLOADS 第三步:进入DOWNLOADS页面之后,将页面往下拉并找到以下图示,点击进入. 第四步:点击MySQL Community Server 第五步 ...
- mysql被除数为0不报错_MySQL:关系除法
哪个司机会开所有类型的车?这便是一个关系除法问题. ##创建表 表drivers有两个字段,司机的名字和司机会开的车的id: CREATE TABLE `drivers` ( `driver_name ...
- 【MySQL】MySQL USE 库的时候报错 Reading table information for completion of table and column names
1.背景 mysql -A不预读数据库信息(use dbname 更快) -Reading table information for completion of table and column n ...
最新文章
- 有史以来最会写代码的农民诞生!腾讯元老、上市公司CTO赚够钱后辞职!到安徽农村隐居,亲手建造200亩农场!...
- 第二单元 考点6-7商业银行和投资理财
- 2735:八进制到十进制-poj
- 2021算法竞赛入门班第一节课【枚举、贪心】习题
- SAP Spartacus UnitDetailsComponent对应的UI插入,是在路由框架里完成的
- python封装 继承 多态 举例_python面向对象中的封装、继承、多态
- bing搜索php,PHP 使用bing搜索网站的api封装类用法
- POJ - 2182 Lost Cows【线段树】
- python数据分析常用类库(1.1)
- 练习五十一:序列交换
- Okhttp 与 Retrofit的简单介绍及两者间的联系
- 制作U盘启动的并可保持更改更新和设置的BT4最终版完全手册
- gitz之忽略warning:LF will be replaced by CRLF
- 微信小程序 图标的角标实现
- OpenNLP进行中文命名实体识别(上:预处理及训练模型)
- 吃透JAVA的Stream流操作,多年实践总结
- 大数据与智慧城市建设论坛
- 【航拍干货】航测区域重点建筑物精细化建模航拍技巧
- 端到端的图像压缩----《Joint Autoregressive and Hierarchical Priors for Learned Image Compression》 论文笔记
- 2010 我的求职经历(3)
热门文章
- SAP Cloud Connector里的virtual host和internal host有什么区别
- How to resolve empty table CRMATAB issue in ERP gt_crmtab[]
- How does ABAP check table work
- 使用代码创建SAP Sales area
- 使用cf push命令往CloudFoundry上部署应用的过程分析
- mysql数据库财务_MySQL数据库——从入门到删库跑路(二)
- java中搭建流水线,部署流水线搭建小记:Docker、Jenkins、Java 和 Couchbase
- redis存储新闻列表_Redis对象——集合(Set)
- python怎么只打印其中一行_如何在Python中让两个print()函数的输出打印在一行内?...
- 二叉树的层序遍历 IIPython解法