MySQL安装

Posted Aimmi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL安装相关的知识,希望对你有一定的参考价值。

安装mysql

一、下载MySQLyum源

wegt httpd://repo.mysql.com/mysql-communtiy-release-e17-5.noarch.rpm

创建MySQLyum源

rpm-ivh mysql-community-release-e17-5.noarch.rpm

安装MySQL服务端

yum -y install mysql-server

设置开机启动

systemctl enable mysql && systemctl start mysqld

二、密码要求:

密码要至少包含:

一个大写字母

一个小写字母

一个数字

一个特殊字符

密码长度不小于8

user分为host为localhost与%的用户:

User@% 允许从所有的ip访问. User@localhost 只允许从localhost访问。

三、SQL语句有三种类型:

DDL:Data Defination Language,数据定义语言 (结构)

DML:Data ManipulationLanguage,数据操纵语言 (数据)

DCL:Data Control Language,数据控制语言

SQL语句类型 对应操作
DDL create:创建
  drop:删除
  alter: 修改
DML insert:向表中插入数据
  delete:删除表格中的数据
  update:更新表格中的数据
  select:查询表格中的数据
DCL grant:授权
  revoke: 移除授权

四、MySQL客服端命令

MySQL客服端命令官方文档

mysql> help

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.
nopager   (\\n) Disable pager, print to stdout.
notee     (\\t) Don\'t write into outfile.
pager     (\\P) Set PAGER [to_pager]. Print the query results via PAGER.
print     (\\p) Print current command.
prompt    (\\R) Change your mysql prompt.
quit      (\\q) Quit mysql.
rehash    (\\#) Rebuild completion hash.
source    (\\.) Execute an SQL script file. Takes a file name as an argument.
status    (\\s) Get status information from the server.
system    (\\!) Execute a system shell command.
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.
resetconnection(\\x) Clean session context.
query_attributes(\\) Sets string parameters (name1 value1 name2 value2 ...)
for the next query to pick up.

For server side help, type \'help contents\'

常用:

clear, \\c

清空当前的输入,实例:

mysql> select wrong
    -> \\c
mysql>

connect [db_name [host_name]], \\r [db_name [host_name]]

重新连接指定主机下的数据库

delimiter str, \\d str

指定SQL语句分界符号,默认为:

prompt [str], \\R [str]

修改提示符为指定的字符串

resetconnection, \\x

HELP命令的使用

mysql> 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
   Data Definition
   Data Manipulation
   Data Types
   Functions
   Functions and Modifiers for Use with GROUP BY
   Geographic Features
   Language Structure
   Plugins
   Storage Engines
   Stored Routines
   Table Maintenance
   Transactions
   Triggers

可以使用%与_进行命令的匹配:

mysql> HELP rep%
Many help items for your request exist.
To make a more specific request, please type \'help <item>\',
where <item> is one of the following
topics:
   REPAIR TABLE
   REPEAT FUNCTION
   REPEAT LOOP
   REPLACE
   REPLACE FUNCTION

以上是关于MySQL安装的主要内容,如果未能解决你的问题,请参考以下文章

从mysql的片段中加载ListView

连接MySQL出现错误:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)(代码片段

使用 json rereiver php mysql 在片段中填充列表视图

在Tomcat的安装目录下conf目录下的server.xml文件中增加一个xml代码片段,该代码片段中每个属性的含义与用途

PHP代码-psysh调试代码片段工具

关于mysql驱动版本报错解决,Cause: com.mysql.jdbc.exceptions.jdbc4Unknown system variable ‘query_cache_size(代码片段