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数据 ...
随机推荐
- iptables中增加/删除/查询/修改的基本操作
虽然在Ubuntu使用了UFW来简化iptables的操作,但是UFW只针对防火墙方面,转发方面没有涉及,所以要弄懂其中的原理,还是必须回归到iptables中.CentOS也是如此.下面是针对ipt ...
- Memcached高可用方案收集(集群及分布式)
Memcached的集群方案有很多,不止magent一个,但是单靠集群软件去实现高可用感觉还是会缺少一步,最推荐的方案应该是软件加编码去实现高可用,至少能保证站点的99.5%的可运行行,以下是集群的方 ...
- Node & Express: some tips
1. 设置Express端口号: 在app.js中添加 app.set('port', process.env.PORT || 3000); 之后命令行中打入 PORT=1234 node app.j ...
- Oracle基础(四)pl/sql
PL/SQL也是一种程序语言,叫做过程化SQL语言(Procedural Language/SQL). PL/SQL是Oracle数据库对SQL语句的扩展.在普通SQL语句的使用上添加了编程语言的特点 ...
- Hibernate插入错误:GenericJDBCException: could not insert:
数据库中一般不能建立user(表名为User)表,将User类改名,又一次建立映射,问题就能够解决 当然,还有还有一种情况.就是类中id类型错误.要设置为Integer型才干够设置自己主动增长,否则也 ...
- HDU 1421 搬寝室 (线性dp 贪心预处理)
搬寝室 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submis ...
- luogu 3383【模板】线性筛素数
我太菜了 %韩神 #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib&g ...
- 【POJ 1716】 Integer Intervals
[题目链接] 点击打开链接 [算法] 差分约束系统 [代码] #include <algorithm> #include <bitset> #include <cctyp ...
- algorithm库———count&&countif
algorithm头文件定义了一个count的函数,其功能类似于find.这个函数使用一对迭代器和一个值做参数,返回这个值出现次数的统计结果. 编写程序读取一系列int型数据,并将它们存储到vecto ...
- Java - HashTable、HashMap和LinkedHashMap的区别
一般情况下,我们用的最多的是HashMap,在Map 中插入.删除和定位元素,HashMap 是最好的选择.但如果您要按自然顺序或自定义顺序遍历键,那么TreeMap会更好.如果需要输出的顺序和输入的 ...