mysql management note
related url :
http://willvvv.iteye.com/blog/1563345
http://lxneng.iteye.com/blog/451985 这篇文章对variables和 status的使用 写的很好!
---------------------------------------------------------登陆--------------------------------------------------------------------
1.mysql -h192.168.0.181 -utest -ptest;
登陆mysql命令行
-------------------------------------------------------数据库操作---------------------------------------------------------------
1.show databases;
查看所有数据库
2.use mydb;
使用mydb数据库
3.drop database if exists `mydb`;
如果数据库mydb存在就drop掉
4.create database `mydb`;
创建mydb数据库
----------------------------------------------------用户权限管理---------------------------------------------------------------
1.grant all privileges on mydb.* to YOURUSER@'%.%' IDENTIFIED BY "YOURPASSWORD";
授权YOURUSER用户可以从任意主机使用YOURPASSWORD对mydb数据库做任何操作
2.revoke all privileges on mydb.* from YOURUSER@'%';
撤销YOURUSER从任意主机操作mydb的权限
3.flush privileges;
使grant和revoke授权生效!执行grant或revoke之后再执行!
---------------------------------------------------------数据表操作-------------------------------------------------------------
1.show tables from mydb;
查看mydb库中所有数据表
2.desc mydb.mytable;
查看mydb库中mytable表的所有列名称,类型,是否为空,默认值,索引等
3.show create table mydb.mytable;
查看mydb库中mytable表的建表SQL语句
4.select * from mydb.mytable\G;
查看mydb库中mytable表的所有内容,以每行数据,列名-值的键值对方式查看。
5.alter table mydb.mytable rename mydb.mytablenew;
表mytable改名为mytablenew
6.alter table mydb.mytable add column newColumn varchar(64) DEFAULT NULL COMMENT '新列备注';
mydb库中mytable表新增一列,名称为newColumn,类型为varchar(64),默认为null,备注是“新列备注”
7.alter table mydb.mytable modify column `modifyColumn ` varchar(16) DEFAULT NULL COMMENT '修改列备注';
修改mydb库中mytable表中列modifyColumn,类型为varchar(16),默认为null,备注是“修改列备注”
8.truncate table mydb.mytable
清空mydb库mytable表的数据,比delete快很多
----------------------------------------------------------数据备份恢复---------------------------------------------------------
1.mysqldump --opt --user=YOURS --password=YOURS -B "mydb1 mydb2" --max_allowed_packet=1048576 --net_buffer_length= 16384 > /data/backup/20120630.sql
将数据库mydb1和mydb2以sql语句形式导出到 /data/backup/20120630.sql文件中
2.source /data/backup/mydb.sql
执行文件中的sql语句
-----------------------------------------------------MySQL状态---------------------------------------------------------------
1.show processlist;
查看当前MySQL连接
2.kill ID;
断掉某个客户端连接,ID是show processlist命令输出第一列的值
3.show variables;
查看MySQL各种变量值
4.show global status;
查看MySQL的各种状态,cacti监控MySQL的原理就是定时收集这些状态值绘图
http://lxneng.iteye.com/blog/451985 这篇文章对variables和 status的使用 写的很好!
5.select version(),current_date();
查看当前数据版本和日期
6.show engine innodb status;
查看innodb引擎状态
7.show table status from test like 'mydb.mytable'
查看innodb表状态
mysql management note的更多相关文章
- winserver2008 management note
1,磁盘online及介质保护 Windows server 2008 增加的磁盘无法初始化-提示:介质受写入保护.插了下相关说明,在VMware的帖子找到了解决办法: 开始-运行,cmd.打开命令提 ...
- mysql下面的INSTALL-BINARY的内容,所有的mysql的配置内容都在这
2.2 Installing MySQL on Unix/Linux Using Generic Binaries Oracle provides a set of binary distributi ...
- Installing MySQL Server
Installing MySQL Server Here we will learn how to Compile and Install the MySQL Server from source c ...
- How to Install MySQL on CentOS 7
CentOS 7的yum源中貌似没有正常安装mysql时的mysql-sever文件,需要去官网上下载 # wget http://dev.mysql.com/get/mysql-communit ...
- MySQL之mysql命令使用详解
MySQL Name mysql - the MySQL command-line tool Synopsis mysql [options] db_name Description mysql is ...
- 第四模块:网络编程进阶&数据库开发 第2章·MySQL数据库开发
01-MySQL开篇 02-MySQL简单介绍 03-不同平台下安装MySQL 04-Windows平台MySQL密码设置与破解 05-Linux平台MySQL密码设置与破解 06-Mac平台MySQ ...
- Mysql 中完善的帮助命令
Mysql 中完善的帮助命令 Mysql 中的帮助系统很完善,很多操作都可以通过命令行直接获得帮助,如下示例: Mysql 命令行帮助 [root@mysql1 mydata1]# mysql -S ...
- mysql基础之帮助信息
在mysql中获取帮助 1.当连接到mysql数据库以后,使用help命令或者\?表示获取帮助信息: MariaDB [ren]> help General information about ...
- MySQL学习笔记01_数据库基础知识
01_1 mysql数据库启动与停止 以<管理员权限>启动cmd: 输入net stop mysql停止mysql服务: 输入net start mysql启动mysql服务: 输入mys ...
随机推荐
- QT学习之-HelloWorld
实现HelloWorld有2种方法. 第一种在mainwindow.ui直接添加Label且写上“HelloWorld”. 第二种是代码直接实现 #include "mainwindow.h ...
- Bootstrap页面布局5 - 响应式布局(格式)
旨在优化不同上网设备中页面显示的优化 响应式布局:就是根据浏览窗口的尺寸,改变页面的变化 原理:利用css的media-queries判断浏览窗口的尺寸,在CSS样式表中设置一些规则! 例如: 在&l ...
- Bootstrap页面布局2 - 包含BS文件
如图所示: bootstrap布局基于HTML5,为了使IE8以下也能使用某些HTML5的标签,必须要引入文件:http://html5shiv.googlecode.com/svn/trunk/ht ...
- sentinel
Computer Science An Overview _J. Glenn Brookshear _11th Edition Inherent in processing a sequential ...
- The "get" method should be used when the form is idempotent---正交的两个概念---
https://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.1 17.13.1 Form submission method The me ...
- linux 输入java 出现中文乱码
http://jingyan.baidu.com/article/ab69b270de8b4f2ca7189f1d.html 1.查看当前linux的编码 没设置之前是:zh_CN.UTF_8 输入 ...
- Comparable与Comparator
转载 Comparable与Comparator的区别 (转载) Comparable & Comparator 都是用来实现集合中元素的比较.排序的,只是 Comparable 是在集合内部 ...
- js中!!的作用
js中!!的作用是: !!一般用来将后面的表达式转换为布尔型的数据(boolean) ===表示类型什么的全部相等(自己写一个if测试一下就好了)!==表示要全部不想等包括类型(一样写一个if)||或 ...
- mysql integer size 大小
I was always wondering what the size of numeric columns in MySQL was. Forgive me if this is obvious ...
- [LeetCode]题解(python):110 Balanced Binary Tree
题目来源 https://leetcode.com/problems/balanced-binary-tree/ Given a binary tree, determine if it is hei ...