CentOS7下mariadb日常管理
在CentOS7下,官方提供的mysql的rpm包就是mariadb,可查看mariadb包信息
[root@host ~]$rpm -qi mariadb # 需要先安装该包
Name : mariadb # 名称
Epoch : 1
Version : 5.5.52 # 版本
Release : .el7 # 发行版
Architecture: x86_64 # 支持安装的CPU架构
Install Date: Mon Apr :: AM CST # 安装时间
Group : Applications/Databases
Size :
License : GPLv2 with exceptions and LGPLv2 and BSD
Signature : RSA/SHA256, Mon Nov :: AM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : mariadb-5.5.-.el7.src.rpm
Build Date : Tue Nov :: AM CST
Build Host : c1bm.rdu2.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://mariadb.org
Summary : A community developed branch of MySQL
Description : # 描述
MariaDB is a community developed branch of MySQL.
MariaDB is a multi-user, multi-threaded SQL database server.
It is a client/server implementation consisting of a server daemon (mysqld)
and many different client programs and libraries. The base package
contains the standard MariaDB/MySQL client programs and generic MySQL files.
根据最后一项——Description描述,MariaDB属于MySQL的社区开发分支。
同时,MariaDB是一款支持多用户、多线程的SQL数据库服务器。
MariaDB采用C/S架构,mysqld作为服务器进程,还有许多的客服端程序和库。
客户端命令mysql
格式
mysql [OPTIONS] [database]
常用选项
-u, --user=username:用户名,默认为root;
-h, --host=hostname:远程主机(即mysql服务器)地址,默认为localhost; 客户端连接服务端,服务器会反解客户的IP为主机名,关闭此功能(skip_name_resolve=ON);
-p, --password[=PASSWORD]:USERNAME所表示的用户的密码; 默认为空; 注意:mysql的用户账号由两部分组成:'USERNAME'@'HOST'; 其中HOST用于限制此用户可通过哪些远程主机连接当前的mysql服务;
HOST的表示方式,支持使用通配符:
%:匹配任意长度的任意字符;
172.16.%.%, 172.16.0.0/
_:匹配任意单个字符; -P, --port=#:mysql服务器监听的端口;默认为3306/tcp;
-S, --socket=/PATH/TO/mysql.sock:套按字文件路径;
-D, --database=DB_name:连接到服务器端之后,设定其处指明的数据库为默认数据库;
-e, --execute='SQL STATEMENT':连接至服务器并让其执行此命令后直接返回;
注:在上面的选项中,选项和参数之间可以不使用空格分开。
示例登录mysql
[root@host ~]$mysql -uroot -p #账号root, 选项和参数可以不分开
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is
Server version: 5.5.-MariaDB MariaDB Server Copyright (c) , , Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> # 表示登录成功
查看客户端常见命令
MariaDB [(none)]> help General information about MariaDB can be found at
http://mariadb.org List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
? (\?) Synonym for `help'. # 查看帮助
clear (\c) Clear the current input statement. # 清空当前输入的语句
connect (\r) Reconnect to the server. Optional arguments are db and host. # 重新连接服务器
delimiter (\d) Set statement delimiter. # 设置语句分隔符(结束符),默认为分号';'
edit (\e) Edit command with $EDITOR. # 编辑命令
ego (\G) Send command to mysql server, display result vertically. # 发送命令至服务器,垂直显示结果
exit (\q) Exit mysql. Same as quit. # 退出
go (\g) Send command to mysql server. # 发送命令至服务器
help (\h) Display this help. # 查看帮助
quit (\q) Quit mysql. # 退出
source (\.) Execute an SQL script file. Takes a file name as an argument. # 读取SQL脚本
system (\!) Execute a system shell command. # 执行shell命令
tee (\T) Set outfile [to_outfile]. Append everything into given outfile. # 设置输出文件
use (\u) Use another database. Takes database name as argument. # 指定数据库
charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. # 指定字符集
warnings (\W) Show warnings after every statement. # 显示警告信息
nowarning (\w) Don't show warnings after every statement. # 不显示警告信息
查看mysql服务端帮助信息,可使用help contents:
MariaDB [(none)]> help contents
You asked for help about help category: "Contents"
For more information, type 'help <item>', where <item> is one of the following
categories:
Account Management # 账户管理语句
Administration # 管理员
Compound Statements
Data Definition # 数据定义语句
Data Manipulation # 数据操作语句
Data Types # 数据类型
Functions # 函数
Functions and Modifiers for Use with GROUP BY
Geographic Features
Help Metadata
Language Structure
Plugins
Procedures
Table Maintenance
Transactions
User-Defined Functions
Utility
要查看某一类命令或者某单一命令使用,均可使用help KEYWORD查看,例如:
MariaDB [(none)]> help Data Definition;
You asked for help about help category: "Data Definition"
For more information, type 'help <item>', where <item> is one of the following
topics:
ALTER DATABASE
ALTER EVENT
ALTER FUNCTION ... RENAME TABLE
TRUNCATE TABLE
MariaDB [(none)]> help create table;
Name: 'CREATE TABLE'
Description:
Syntax:
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
(create_definition,...)
[table_options]
[partition_options] Or: CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
[(create_definition,...)]
[table_options]
[partition_options]
select_statement Or: CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
{ LIKE old_tbl_name | (LIKE old_tbl_name) } ...
数据类型
自动增长类型
AUTO_INCREMENT
字符型:
char/binary varchar/varbinary
text/ngtext/blob/ediumblob/longblob
set/enum
数值型
int/tinyint/smallint/mediumint/bigint
decimal
float/double
日期型
date/time/datetime/timestamp/year(,)
常见数据库管理语句
选择操作的数据库
USE db_name
创建
CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name;
[DEFAULT] CHARACTER SET [=] charset_name # 设置字符集
[DEFAULT] COLLATE [=] collation_name # 设置排序方式
SHOW CHARACTER SET # 查看支持的所有的字符集
SHOW COLLATION # 查看支持的所有排序方式
修改
ALTER {DATABASE | SCHEMA} [db_name]
删除
DROP {DATABASE | SCHEMA} [IF EXISTS] db_name
查看
SHOW {DATABASES | SCHEMAS}
[LIKE 'pattern' | WHERE expr]
表管理
创建
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
(create_definition,...) # 字段定义
[table_options] # 数据表的基本设置
[partition_options] # 分割选项
修改
ALTER [ONLINE | OFFLINE] [IGNORE] TABLE tbl_name
[alter_specification [, alter_specification] ...]
[partition_options]
删除
DROP [TEMPORARY] TABLE [IF EXISTS]
tbl_name [, tbl_name] ...
[RESTRICT | CASCADE]
DML数据操作语言
查看
SELECT
[ALL | DISTINCT | DISTINCTROW ]
[HIGH_PRIORITY]
[STRAIGHT_JOIN]
[SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
[SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS]
select_expr [, select_expr ...]
[FROM table_references
[WHERE where_condition]
[GROUP BY {col_name | expr | position}
[ASC | DESC], ... [WITH ROLLUP]]
[HAVING where_condition]
[ORDER BY {col_name | expr | position}
[ASC | DESC], ...]
[LIMIT {[offset,] row_count | row_count OFFSET offset}]
[PROCEDURE procedure_name(argument_list)]
[INTO OUTFILE 'file_name'
[CHARACTER SET charset_name]
export_options
| INTO DUMPFILE 'file_name'
| INTO var_name [, var_name]]
[FOR UPDATE | LOCK IN SHARE MODE]]
插入
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name [(col_name,...)]
{VALUES | VALUE} ({expr | DEFAULT},...),(...),...
[ ON DUPLICATE KEY UPDATE
col_name=expr
[, col_name=expr] ... ]
删除
Single-table syntax: DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count] Multiple-table syntax: DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]
修改
Single-table syntax: UPDATE [LOW_PRIORITY] [IGNORE] table_reference
SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count] Multiple-table syntax: UPDATE [LOW_PRIORITY] [IGNORE] table_references
SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
[WHERE where_condition]
权限管理(账户管理)
创建用户
CREATE USER user_specification
[, user_specification] ... user_specification:
user
[
IDENTIFIED BY [PASSWORD] 'password'
| IDENTIFIED WITH auth_plugin [AS 'auth_string']
]
删除用户
DROP USER user [, user] ...
向用户授权
GRANT
priv_type [(column_list)]
[, priv_type [(column_list)]] ...
ON [object_type] priv_level
TO user_specification [, user_specification] ...
[REQUIRE {NONE | ssl_option [[AND] ssl_option] ...}]
[WITH with_option ...] GRANT PROXY ON user_specification
TO user_specification [, user_specification] ...
[WITH GRANT OPTION]
取消授权或者调整权限
REVOKE
priv_type [(column_list)]
[, priv_type [(column_list)]] ...
ON [object_type] priv_level
FROM user [, user] ... REVOKE ALL PRIVILEGES, GRANT OPTION
FROM user [, user] ... REVOKE PROXY ON user
FROM user [, user] ...
CentOS7下mariadb日常管理的更多相关文章
- Centos7下创建和管理用户
centos服务管理主要命令是systemctl,centos7的服务不再放在/etc/init.d/下;而放在/usr/lib/systemd/system下,centos7系统中systemctl ...
- CentOS7下MariaDB数据库安装及配置
前言 MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品.在存 ...
- mysql下mysqladmin日常管理命令总结
mysqladmin 工具的使用格式:mysqladmin [option] command [command option] command ......参数选项:-c number 自动运行次数统 ...
- Centos7 下mariadb安装
1.创建 /etc/yum.repos.d/MariaDB.repo vim /etc/yum.repos.d/MariaDB.repo 添加如下内容: [mariadb]name=MariaDB ...
- centos7下mysql 用户管理和权限设置
1.进入mysql命令行,输入root及密码[root@localhost ~]# mysql -u root -pEnter password: Welcome to the MySQL monit ...
- MariaDB Centos7 下安装MariaDB
Centos7 下安装MariaDB by:授客 QQ:1033553122 1.下载安装文件 rpm包为例,对于标准服务器安装,至少需要下载client,shared,serve文件(安装时如果少了 ...
- centos7下搭建nginx+php7.1+mariadb+memcached+redis
一.环境准备 1.首先介绍一下环境,以及我们今天的主角们 我用的环境是最小化安装的centos7,mariadb(江湖传言mysql被oracle收购后,人们担心像java一样毁在oracle手上于是 ...
- CentOS7下安装MariaDB
环境:Window10 上建立 VMWare 虚拟机,EasyInstaller 方式安装 CentOS 7 1. “失败”的经历 备份原 repo 文件,并更改 yum 源(方法详见修改yum源)为 ...
- Linux - centos7 下 MySQL(mariadb) 和 主从复制
目录 Linux - centos7 下 MySQL(mariadb) 和 主从复制 MySQL(mariadb) 安装MySQL(mariadb) 配置数据库的中文支持 在远程用 mysql客户端去 ...
随机推荐
- 洛谷P4092 [HEOI2016/TJOI2016]树 并查集/树链剖分+线段树
正解:并查集/树链剖分+线段树 解题报告: 传送门 感觉并查集的那个方法挺妙的,,,刚好又要复习下树剖了,所以就写个题解好了QwQ 首先说下并查集的方法趴QwQ 首先离线,读入所有操作,然后dfs遍历 ...
- Oracle单行函数
一.尽管各个数据库都是支持sql语句的.可是每一个数据库也有每一个数据库所支持的操作函数,这些就是单行函数.假设想进行数据库开发的话.除了要回使用sql语句外,就是要多学习函数. 1.单行函数的分类: ...
- java框架之SpringBoot(8)-嵌入式Servlet容器
前言 SpringBoot 默认使用的嵌入式 Servlet 容器为 Tomcat,通过依赖关系就可以看到: 问题: 如何定制和修改 Servlet 容器相关配置? SpringBoot 能否支持其它 ...
- python框架之Django(15)-contenttype模块
假如有一个书城系统,需要给作者和书籍加上评论功能.如果给每个表单独建一个评论表,那么我们以后要扩展其它模块评论功能的时候,还需要随之新建一张评论表,会显得很冗余.对于这种情况,Django 给我们提供 ...
- Linux的is not in the sudoers file 解决
https://blog.csdn.net/hxpjava1/article/details/79566822
- Android adt-bundle 开发环境的搭建_Linuxs
本文完全是拷贝的: https://www.jb51.net/article/87957.htm 的文章, 有需要请看原文, 拷贝仅用于学习记录. 本文与<利用adt-bundle轻松搭建An ...
- window中普通用户无法登录远程桌面
解决方案就是将该用户加到 Remote Desktop Users 这个用户组中. 使用命令 net localgroup "Remote Desktop Users" 用户名 / ...
- linux 生成密钥,并向git服务器导入公钥
1. server1 上使用haieradmin用户 ,先清理之前的ssh登录记录,rm –rf ~/.ssh , 运行ssh-keygen –t rsa(只需回车下一步即可,无需输入任何密 ...
- Gis数据处理
几何投影和解析投影几何投影是将椭球面上的经纬线网投影到几何平面上,然后将几何面展为平面.几何投影可以分为方位投影.圆柱投影和圆锥投影.这三种投影纬线的形状不同.方位投影纬线的形状是同心圆:圆柱投影纬线 ...
- app 开发
移动APP开发 ios Android 中国人写的 MUI 布局框架 HTML5plus 硬件驱动调用(打开摄像头,闪光灯,震动) 和 系统调用(打开相册,通讯录,message) http:/ ...