设为首页 加入收藏

TOP

MySQL创建用户与授权方法、MySQL查看版本号、MySQL执行SQL脚本的方法(一)
2017-11-24 10:48:56 】 浏览:512
Tags:MySQL 创建 用户 授权 方法 查看 版本 执行 SQL 脚本

-------------------帮助的使用----------------------

使用MySQL安装后自带的帮助文档

--按照层次看帮助

显示所有可供查询的的分类:contents

“类别名称”的方式针对用户感兴趣的内容做进一步的查看

example:

mysql> ? data types

--查看 MySQL 中都支持哪些数据类型

mysql> ? BINARY

--查看类型的具体介绍

Name: 'BINARY'

Description:

BINARY(M)

The BINARY type is similar to the CHAR type, but stores binary byte

strings rather than nonbinary character strings. M represents the

column length in bytes.

URL: https://dev.mysql.com/doc/refman/8.0/en/string-type-overview.html

--快速查阅帮助

快速查阅某项语法--MySQL对空格貌似比较敏感

example:

mysql> ? create table

--常用的网络资源

-------------------查看版本号----------------------

--1.使用命令行模式进入mysql会看到最开始的提示符

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 15

Server version: 8.0.0-dmr-log MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

--2.命令行中使用status可以看到

mysql> status;

--------------

mysql Ver 14.14 Distrib 8.0.0-dmr, for Win64 (x86_64)

Connection id: 15

Current database:

Current user: root@localhost

SSL: Not in use

Using delimiter: ;

Server version: 8.0.0-dmr-log MySQL Community Server (GPL)

Protocol version: 10

Connection: localhost via TCP/IP

Server characterset: utf8

Db characterset: utf8

Client characterset: utf8

Conn. characterset: utf8

TCP port: 3306

Uptime: 12 hours 26 min 47 sec

Threads: 1 Questions: 118 Slow queries: 0 Opens: 292 Flush tables: 2 Open tables: 268 Queries per second avg: 0.002

--------------

--3.使用系统函数

mysql> select version();

+---------------+

| version() |

+---------------+

| 8.0.0-dmr-log |

+---------------+

1 row in set (0.00 sec)

--4. $ mysql --help | grep Distrib

mysql Ver 14.14 Distrib 5.1.69, for redhat-linux-gnu (x86_64) using readline 5.1

--5.5 包管理工具(根据不同系统 rh系列或则是bsd系列)

$ rpm -qa|grep mysql

qt-mysql-4.6.2-20.el6.x86_64

mysql-server-5.1.69-1.el6_4.x86_64

mysql-libs-5.1.69-1.el6_4.x86_64

mysql-5.1.69-1.el6_4.x86_64

mysql-devel-5.1.69-1.el6_4.x86_64

-------------------MySQL创建用户与授权方法----------------------

--在MySQL查看MySQL的安装目录

mysql> select @@basedir;

+------------------------------------------------+

| @@basedir |

+------------------------------------------------+

| C:\Program Files (x86)\MySQL\MySQL Server 5.1\ |

+------------------------------------------------+

1 row in set (0.00 sec)

--创建用户及授权

CREATE USER 'lin'@'localhost' IDENTIFIED BY 'mypass';

grant all on *.* to 'lin'@'localhost';

https://www.jb51.net/article/31850.htm

https://www.cnblogs.com/bethal/p/5512755.html

-------------------MySQL执行SQL脚本的方法----------------------

1.在命令行下(未连接数据库),输入 mysql -h localhost -u root -p123456 < F:\hello world\niuzi.sql (注意路径不用加引号的!!) 回车即可.

2.在命令行下(已连接数据库,此时的提示符为 mysql> ),输入

source F:\hello world\niuzi.sql (注意路径不用加引号的) 或者

\. F:\hello world\niuzi.sql (注意路径不用加引号的) 回车即可

-------------------MySQL支持的数据类型----------------------

--1.数值类型

如果超出类型范围的操作,会发生 “Out of range ”错误提示。

如果不显示指定宽度则默认为 int(11)。

一般配合 zerofill 使用,顾名思义,zerofill 就是用“0”填充的意思,也就是在数字位数不够

的空间用字符“0”填满。

--zerofill的使用

mysql> alter table t1 modify id2 int(5) zerofill;

+------------+-------

首页 上一页 1 2 3 4 5 下一页 尾页 1/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇SQL之DECIMAL函数详解 下一篇MySQL的导入导出的操作步骤

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目