Ubuntu Mysql 常用指令
mysql 常用指令及中文乱码解决
*:first-child {
margin-top: 0 !important;
}
body>*:last-child {
margin-bottom: 0 !important;
}
/* BLOCKS
=============================================================================*/
p, blockquote, ul, ol, dl, table, pre {
margin: 15px 0;
}
/* HEADERS
=============================================================================*/
h1, h2, h3, h4, h5, h6 {
margin: 20px 0 10px;
padding: 0;
font-weight: bold;
-webkit-font-smoothing: antialiased;
}
h1 tt, h1 code, h2 tt, h2 code, h3 tt, h3 code, h4 tt, h4 code, h5 tt, h5 code, h6 tt, h6 code {
font-size: inherit;
}
h1 {
font-size: 28px;
color: #000;
}
h2 {
font-size: 24px;
border-bottom: 1px solid #ccc;
color: #000;
}
h3 {
font-size: 18px;
}
h4 {
font-size: 16px;
}
h5 {
font-size: 14px;
}
h6 {
color: #777;
font-size: 14px;
}
body>h2:first-child, body>h1:first-child, body>h1:first-child+h2, body>h3:first-child, body>h4:first-child, body>h5:first-child, body>h6:first-child {
margin-top: 0;
padding-top: 0;
}
a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
margin-top: 0;
padding-top: 0;
}
h1+p, h2+p, h3+p, h4+p, h5+p, h6+p {
margin-top: 10px;
}
/* LINKS
=============================================================================*/
a {
color: #4183C4;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
/* LISTS
=============================================================================*/
ul, ol {
padding-left: 30px;
}
ul li > :first-child,
ol li > :first-child,
ul li ul:first-of-type,
ol li ol:first-of-type,
ul li ol:first-of-type,
ol li ul:first-of-type {
margin-top: 0px;
}
ul ul, ul ol, ol ol, ol ul {
margin-bottom: 0;
}
dl {
padding: 0;
}
dl dt {
font-size: 14px;
font-weight: bold;
font-style: italic;
padding: 0;
margin: 15px 0 5px;
}
dl dt:first-child {
padding: 0;
}
dl dt>:first-child {
margin-top: 0px;
}
dl dt>:last-child {
margin-bottom: 0px;
}
dl dd {
margin: 0 0 15px;
padding: 0 15px;
}
dl dd>:first-child {
margin-top: 0px;
}
dl dd>:last-child {
margin-bottom: 0px;
}
/* CODE
=============================================================================*/
pre, code, tt {
font-size: 12px;
font-family: Consolas, "Liberation Mono", Courier, monospace;
}
code, tt {
margin: 0 0px;
padding: 0px 0px;
white-space: nowrap;
border: 1px solid #eaeaea;
background-color: #f8f8f8;
border-radius: 3px;
}
pre>code {
margin: 0;
padding: 0;
white-space: pre;
border: none;
background: transparent;
}
pre {
background-color: #f8f8f8;
border: 1px solid #ccc;
font-size: 13px;
line-height: 19px;
overflow: auto;
padding: 6px 10px;
border-radius: 3px;
}
pre code, pre tt {
background-color: transparent;
border: none;
}
kbd {
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
background-color: #DDDDDD;
background-image: linear-gradient(#F1F1F1, #DDDDDD);
background-repeat: repeat-x;
border-color: #DDDDDD #CCCCCC #CCCCCC #DDDDDD;
border-image: none;
border-radius: 2px 2px 2px 2px;
border-style: solid;
border-width: 1px;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
line-height: 10px;
padding: 1px 4px;
}
/* QUOTES
=============================================================================*/
blockquote {
border-left: 4px solid #DDD;
padding: 0 15px;
color: #777;
}
blockquote>:first-child {
margin-top: 0px;
}
blockquote>:last-child {
margin-bottom: 0px;
}
/* HORIZONTAL RULES
=============================================================================*/
hr {
clear: both;
margin: 15px 0;
height: 0px;
overflow: hidden;
border: none;
background: transparent;
border-bottom: 4px solid #ddd;
padding: 0;
}
/* TABLES
=============================================================================*/
table th {
font-weight: bold;
}
table th, table td {
border: 1px solid #ccc;
padding: 6px 13px;
}
table tr {
border-top: 1px solid #ccc;
background-color: #fff;
}
table tr:nth-child(2n) {
background-color: #f8f8f8;
}
/* IMAGES
=============================================================================*/
img {
max-width: 100%
}
-->
Mysql 系统管理指令
- 登陆本地 Mysql
mysql -u username -p # 回车输入密码
或者 mysql -u username -p passswd;
- 登陆远程 Mysql
mysql -h address -u username -p # 回车输入密码
或者 mysql -h address -u username -p passswd;
- 修改新密码
mysql> use mysql;
mysql> update user set password=PASSWORD(‘newpasswd’) where user=’username’;
mysql> flush privileges; #更新权限
mysql> quit; #退出
- 增加新用户
mysql> grant select on database_name.* to user@address identified by ‘passwd’
ex: 增加一个用户 test1 密码为 abc,让他可以在任何主机上登录,并对所有数据库有 查询、插入、修改、删除的权限。
- mysql> grant select,insert,update,delete on . to root@localhost identified by 'mysql';
- or mysql> grant all privileges on . to root@localhost identified by 'mysql';
- mysql> flush privileges;
ex: 不希望 root 有密码操作数据库“mydb”里的数据表,可以再打一个命令将密码消掉
- mysql> grant select,insert,update,delete on mydb.* to root@localhost identified by '';
- 删除用户
mysql> delete from user where user='user_name' and host='address';
mysql> flush privileges;
mysql> drop database dbname; #删除用户的数据库
数据库导入导出(mysqldump)
- 导出所有数据库
mysqldump -u user -p -A > backup_file_path
- 导出数据和数据结构
mysqldump -u user -p database_name_need_to_backup > backup_file_path
ex00: export database mydb
mysqldump -h localhost -u root -p mydb > ./mydb.sql
ex01: export database mydb mytable
mysqldump -h localhost -u root -p mydb mytable > ./mytable.sql
ex02: export database mydb framework
mysqldump -h localhost -u root -p mydb –add-drop-table > ./mydb_stru.sql
- 只导出数据不导出数据结构
mysqldump -u user -p -t database_name_need_to_backup > backup_file_path
- 导出数据库中的Events
mysqldump -u user -p -E database_name_need_to_backup > backup_file_path
- 导出数据库中的存储过程和函数
mysqldump -u user -p -R database_name_need_to_backup > backup_file_path
- 从外部文件导入数据库中
- 使用“source”命令
mysql > source path_of_backup_file
- 使用“<”符号
mysql -u root –p < path_of_backup_file
Mysql 常用指令
- 查看所有数据库
mysql> show databases;
- 选择要操作数据库
mysql> use database_name;
- 查看当前数据库下所有表
mysql> show tables;
- 获取表结构
mysql> desc table_name;
或者 mysql> show columns from table_name;
- 创建一个数据库
mysql> create database database_name;
- 删除一个数据库
mysql> drop database database_name;
- 创建一个表
mysql> create table table_name( uid bigint(20) not null, uname varchar(20) not null);
- 删除一个表
mysql> drop table table_name;
- SQL插入语句
mysql> insert into table_name(col1, col2) values(value1, value2);
- SQL更新语句
mysql> update tablename set col1='value1', col2='value2' where wheredefinition;
- SQL查询语句
mysql> select * from table_name where....... #(最复杂的语句)
- SQL删除语句
mysql> delete from table_name where...
- 增加表结构的字段
mysql> alert table table_name add column field1 date, add column field2 time ...
- 删除表结构的字段
mysql> alert table table_name drop field1;
- 查看表的结构
mysql> show columns from table_name;
- limit 的使用
mysql> select * from table_name limit 3; #每页只显示3行
mysql> select * from table_name limit 3,4; #从查询结果的第三个开始,显示四项结果。 此处可很好的用来作分页处理。
- 对查询结果进行排序
mysql> select * from table_name order by field1, orderby field2; #多重排序
- 查看字符编码
mysql> show variables like 'character%' ;
Ubuntu mysql中文乱码解决
- 打开配置文件
sudo vim /etc/mysql/my.cnf
- 找到[mysqld]添加
character-set-server = utf8
- 重启mysql
/etc/init.d/mysql restart 或者 service mysql restart
Ubuntu Mysql 常用指令的更多相关文章
- MySQL常用指令,java,php程序员,数据库工程师必备。程序员小冰常用资料整理
MySQL常用指令,java,php程序员,数据库工程师必备.程序员小冰常用资料整理 MySQL常用指令(备查) 最常用的显示命令: 1.显示数据库列表. show databases; 2.显示库中 ...
- Ubuntu下常用指令
James最近因为需要尝试着编译Android源代码,系统环境变成了Ubuntu.和熟悉Windows操作系统环境一样,都有过渡的阶段.下面记录常用的操作指令. 分类目录如下: uname -a 查看 ...
- MySQL常用指令
1.win下启动MySQL 命令行下输入: mysql –h localhost –u root -p / mysql -uroot -p 2.MySql下建表 输入命令 show database ...
- MySQL 常用指令小结
l 创建数据库:CREATE DATABASE table_name; l 删除数据库:DROP DATABASE table_name; l 展示数据库:SHOW DATABASE; l 选 ...
- 管理Mysql常用指令
知识会更新,数据库系统也一样,本文只保证对Mysql 5.7以及MariaDB 10有效. 编码篇 展示当前默认的编码和字符集 SHOW VARIABLES LIKE 'char%'; 修改服务器默认 ...
- mysql 常用指令集合
show variables ——显示系统变量(扩展show variables like 'XXX') 在MYSQL的主从复制中 ,通过命令show master status,可以查看maste ...
- mysql 常用指令
修改表的字符集 88down voteaccepted If you want to change the table default character set and all character ...
- ubuntu linux常用指令(1)
序号 命令 说明 1 sudo su 从普通用户切换到root用户 2 su user 从root用户切换到普通用户 3 ls 列出当前目录的文件和目录,但是不包括隐藏文件和目录 4 ls -a 列出 ...
- Docker Compose 配置文件常用指令
Docker Compose 配置文件常用指令 YAML文件格式及编写注意事项 YAML是一种标记语言很直观的数据序列化格式,可读性高.类似于XML数据描述语言,语法比XML简单的很多. YAML数据 ...
随机推荐
- Mutual Training for Wannafly Union #5
A(UVA12336) 题意:给一个n*m(n,m<=1e5)的棋盘,棋盘上有一些障碍点不能放棋子,现在要在棋盘上放4个棋子,满足A->B->C->D->A,其中走的规则 ...
- MyBatis3-传递多个参数(Multiple Parameters)
传递多个参数一般用在查询上,比如多个条件组成的查询,有以下方式去实现: 版本信息: MyBatis:3.4.4 1.自带方法 <select id="getUserArticlesBy ...
- jq仿苹果的时间/日期选择效果
1.html文件,index.html <!DOCTYPE html> <html lang="en"> <head> <meta cha ...
- 深入学习理解java-ThreadLocal
导读 首先,ThreadLocal 不是用来解决共享对象的多线程訪问问题的,普通情况下,通过ThreadLocal.set() 到线程中的对象是该线程自己使用的对象,其它线程是不须要訪问的,也訪问不到 ...
- iOS 设置启动页面 时间
[NSThread sleepForTimeInterval:3.0]; 时间越大 ,启动页面停留的时间越长 iOS 8之后,,创建项目自带的有 LaunchScreen.xib 可直接用
- LeetCode 725. Split Linked List in Parts (分裂链表)
Given a (singly) linked list with head node root, write a function to split the linked list into k c ...
- tomcat的localhost_access_log日志文件
一.服务器打印日志要关闭hibernate的日志,首先要把hibernate.show_sql设置为false;然后设置log4j.properties. # Control logging for ...
- Bing Maps进阶系列七:Bing Maps功能导航菜单华丽的变身
Bing Maps进阶系列七:Bing Maps功能导航菜单华丽的变身 Bing Maps Silverlight Control所提供的功能导航是非常强大的,在设计上对扩展的支持非常好,提供了许多用 ...
- 特征变化--->标签到向量的转换(OneHotEncoder)
一.One-Hot Encoding One-Hot编码,又称为一位有效编码,主要是采用位状态寄存器来对个状态进行编码,每个状态都由他独立的寄存器位,并且在任意时候只有一位有效. 在实 ...
- codevs1993 草地排水(最大流)
1993 草地排水 USACO 时间限制: 2 s 空间限制: 256000 KB 题目等级 : 钻石 Diamond 题目描述 Description 在农夫约翰的农场上,每逢下雨,Bes ...