MySQl介绍

官方站点:http://www.mysql.com/

MySQL是一个开放源码的小型关联式数据库管理系统。目前MySQL被广泛地应用在Internet上的中小型网站中。由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,许多中小型网站为了降低网站总体拥有成本而选择了MySQL作为网站数据库。

MySQl数据库分类

1)社区版

2)商业版

3)cluster集群

一.安装简介

1)创建mysql用户的账号

首先以root身份登录到Linux系统中,然后执行如下命令创建mysql组及用户账号:

 [root@king ~]# groupadd mysql
[root@king ~]# useradd -s /sbin/nologin -g mysql -M mysql
useradd命令的参数简要说明
    -s/sbin/nologin表示禁止该用户登录,只需要角色存在即可,加强安全。
    -g mysql指定mysql用户属于mysql组。
    -M表示不创建用户家目录,因为没有需要。
    groupadd和useradd这两条命令也可以用useradd-s/sbin/nologin-M mysql替代。

然后检查刚刚创建的mysql用户和组,如下:

 [root@king ~]# tail - /etc/passwd
mysql:x::::/home/mysql:/sbin/nologin
[root@king ~]# id mysql
uid=(mysql)gid=(mysql)组=(mysql)

现在建立一个存放所有安装软件的固定目录,如下:

 [root@king ~]# mkdir -p /home/king/tools
[root@king ~]# cd /home/king/tools/

二.获取MySQL软件包

1.MySQL软件包的下载地址为: https://dev.mysql.com/ ,官网下载示例点我

2.现在以rz命令从本地安装来演示部署过程,执行时如提示无rz命令,可先执行yum install lrzsz-y安装,如下:

 [root@king tools]# cd /home/oldboy/tools/
[root@king tools]# rz
rz waiting to receive.开始zmodem传输。按Ctrl+C取消正在传输mysql-5.5.-linux2.-x86_64.tar.gz...
% KB KB/s :: 错误
[root@king tools]# ls -sh mysql-5.5.-linux2.-x86_64.tar.gz
179M mysql-5.5.-linux2.-x86_64.tar.gz
三 采用二进制方式安装MySQL
(1)解压并移动MySQL二进制软件包到指定的安装路径,命令如下:
 [root@king tools]# tar xf mysql-5.7.-linux2.-x86_64.tar.gz
#<==解压
[root@king tools]# mkdir -p /application/ #<==创建安装目录,如果有就不用创建了
[root@king tools]# mv mysql-5.7.-linux2.-x86_64 /application/mysql-5.7.
#<==移动并改名目录

(2)创建软链接,生成去掉版本号的访问路径并查看,命令如下:

 [root@king tools]# ln -s /application/mysql-5.7./ /application/mysql

三.初始化MySQL数据库文件

初始化命令如下:

 [root@king mysql]# mkdir -p /application/mysql/data
#<==建立MySQL数据文件目录
[root@king mysql]# chown -R mysql.mysql /application/mysql/
#<==授权mysql用户管理MySQL的安装目录
[root@king mysql]# /application/mysql/scripts/mysql_install_db --basedir=
/application/mysql --datadir=/application/mysql/data --user=mysql
#<==初始化MySQL数据库文件,会有很多信息提示,如果没有ERROR级别
的错误,会有两个OK的字样,表示初始化成功,否则就要解决初始化的问题
WARNING: The host 'www' could not be looked up with resolveip.
This probably means that your libc libraries are not % compatible
with this binary MySQL version. The MySQL daemon,mysqld,should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so,start the server,then issue the following commands:
/application/mysql/bin/mysqladmin -u root password 'new-password'
/application/mysql/bin/mysqladmin -u root -h www password 'new-password'
Alternatively you can run:
/application/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /application/mysql;/application/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /application/mysql/mysql-test;perl mysql-test-run.pl
Please report any problems with the /application/mysql/scripts/mysqlbug script!

四.初始化故障排错集锦

错误示例1:WARNING:The host'mysql'could not be looked up with resolveip.
需修改主机名的解析,使其和uname-n一样,修改后的结果如下:

 [root@king mysql]# grep `uname -n` /etc/hosts
127.0.0.1 www localhost.localdomain localhost

错误示例2:ERROR:1004 Can't create file'/tmp/#sql300e_1_0.frm'(errno:13)

原因是/tmp目录的权限有问题。
解决办法为处理/tmp目录,如下:
 [root@king mysql]# ls -ld /tmp
drwxrwxrwt. root root Aug : /tmp
[root@king mysql]# chmod -R /tmp/

五.配置并启动MySQL

1)设置MySQL启动脚本,如下:

 [root@king mysql]# cp support-files/mysql.server /etc/init.d/mysqld
#<==拷贝MySQL启动脚本到MySQL的命令路径
[root@king mysql]# chmod +x /etc/init.d/mysqld
#<==使脚本可执行

2)MySQL二进制默认安装路径是/usr/local/mysql,启动脚本里是/usr/local/mysql的路径都需要替换,如下:

 [root@king mysql]# sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld

3)启动MySQL数据库,如下:

 [root@king mysql]# sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld

4)检查MySQL数据库是否启动,如下:

 [root@king mysql]# netstat -lntup|grep mysql
tcp 0.0.0.0: 0.0.0.0:* LISTEN /mysqld

5)设置MySQL开机自起动,如下:

 [root@king mysql]# chkconfig --add mysqld
[root@king mysql]# chkconfig mysqld on
[root@king mysql]# chkconfig --list mysqld
mysqld :off :off :on :on :on :on :off

6)配置mysql命令的全局使用路径,如下:

 [root@king mysql]# echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile
#<==注意,echo后是单引号,双引号是不行滴。
[root@king mysql]# tail - /etc/profile
export PATH=/application/mysql/bin:$PATH
[root@king mysql]# source /etc/profile
#<==执行source使上一行添加到/etc/profile中的内容直接生效。

7)登陆MySQL数据库,如下

 [root@king mysql]# mysql  #<==直接敲就进入数据库了,而且身份还是root

六.MySQl安全配置

为MySQL的root用户设置密码,命令如下:

 [root@king mysql]# mysqladmin -u root password 'liang123' #<==更改默认密码。
[root@king mysql]# mysql #<==无法直接登录了
ERROR (): Access denied for user 'root'@'localhost'(using password: NO)
[root@king mysql]# mysql -uroot -p #<==新的登录方式
Enter password: #<==输入新密码liang123
Welcome to the MySQL monitor. Commands end with;or \g.
Your MySQL connection id is
Server version: 5.7. MySQL Community Server(GPL)
Copyright(c),,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.
mysql>

MySQL安装与配置介绍的更多相关文章

  1. Centos 7.3下 Linux For SQL Server安装及配置介绍

    Centos 7.3下 Linux For SQL Server安装及配置介绍 高文龙关注13人评论2828人阅读2017-03-05 21:46:21 Centos 7.3下Linux For SQ ...

  2. CentOS 6.5系统使用yum方式安装LAMP环境和phpMyAdmin,mysql8.0.1/mysql5.7.22+centos7,windows mysql安装、配置

    介绍如何在CentOs6.2下面使用YUM配置安装LAMP环境,一些兄弟也很喜欢使用编译的安装方法,个人觉得如果不是对服务器做定制,用yum安装稳定简单,何必去download&make&am ...

  3. MySQL 安装 + 精简 + 配置

    MySQL 安装 + 精简 + 配置 下载安装 从官网 下载 Community Edition MySQL 5.6 版本 精简 根目录下只留 [data/bin/share] , my-defaul ...

  4. 什么是blob,mysql blob大小配置介绍

    什么是blob,mysql blob大小配置介绍 作者: 字体:[增加 减小] 类型:转载   BLOB (binary large object),二进制大对象,是一个可以存储二进制文件的容器.在计 ...

  5. PPTP + FreeRADIUS + MySQL 安装与配置

    原文地址:http://www.zhukun.net/archives/5375 PPTP + FreeRADIUS + MySQL 安装与配置 2012/03/29Linux运维centos.Fre ...

  6. Linux下MySQL安装和配置

    --Linux下MySQL安装和配置 ---------------------------2014/05/18 Linux下MySQL的配置和安装 本文的安装采用 rpm 包安装 1.首先在官网下载 ...

  7. Windows Server 2016 + SCO 2016 安装及配置介绍

    Windows Server 2016 + SCO 2016 安装及配置介绍 高文龙关注1人评论6332人阅读2017-02-26 23:23:02 Windows Server 2016 + SCO ...

  8. MySQL安装、配置、测试

    MySQL安装.配置.测试(win7_64bit) 目录 1.概述 2.本文用到的工具 3.MySQL安装配置 4.Java访问MySQL测试 5.注事事项 6.相关博文 >>看不清的图片 ...

  9. Linux下MySQL安装及配置

    Linux下MySQL安装及配置 安装MySQL Ubuntu系统中,直接使用apt install的方式去安装MySQL的服务端和客户端,MySQL的客户端必须安装,否则无法通过命令连接并操作MyS ...

随机推荐

  1. 《springcloud 二》微服务动态网关,网关集群

    动态网关    实际上是网关和分布式配置中心的整合,通过post手动刷新,生效 动态网关 传统方式将路由规则配置在配置文件中,如果路由规则发生了改变,需要重启服务器.结合整合SpringCloud C ...

  2. spring boot Filter过滤器的简单使用

    springboot使用Filter过滤器有两种方式: 一种是实现Filter接口然后通过@Component注解向项目加入过滤器 另一种是通过配置类来配置过滤器 @Component public ...

  3. Mybatis基础配置及增删查改操作

    一.简介 平时我们都用JDBC访问数据库,除了需要自己写SQL之外,还必须操作Connection, Statement, ResultSet 这些其实只是手段的辅助类. 不仅如此,访问不同的表,还会 ...

  4. Spring注入属性、对象

    对Category和Product注入属性,并且对Product对象,注入一个Category对象 一.新建项目 二.导包 三.新建Category类 package com.yyt.pojo; pu ...

  5. 报错:java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.xxx.entity.PersonEntity

    报错:java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.xxx.entity.PersonEntity 代 ...

  6. 中介者模式和php实现

    中介者模式: 中介者模式(Mediator Pattern)定义:用一个中介对象来封装一系列的对象交互,中介者使各对象不需要显式地相互引用,从而使其耦合松散,而且可以独立地改变它们之间的交互.中介者模 ...

  7. Author: Jan Odvarko, www.janodvarko.cz

    /*  * Author: Jan Odvarko, www.janodvarko.cz */ FBL.ns(function() { with (FBL) { function HelloWorld ...

  8. 【Python图像特征的音乐序列生成】第一阶段的任务分配

    从即日起到7月20号,项目成员进行了第一次任务分配. 赵同学A.岳同学.周同学,负责了图像数据的情感数据集制作,他们根据自己的经验,对图像进行了情绪提取. 赵同学B全权负责向量映射这一块的网络搭建. ...

  9. UI高端课程

    目后佐道IT教育正在打架报名中,欢迎高中生.大学生前来学习编程技术和UI设计,招生面向全国. 石破天惊 前100个报名者免费提供高级公寓居住(里面有空调,暖气,热水器,洗衣机). 赠送神秘课程价值29 ...

  10. SQL Server将列以分隔符分割后存到临时表

    begin if object_id('tempdb..#t') is not null drop table #t; create table #t ( filepath ) ); declare ...