12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
mysql数据库 时间:2024-12-24 19:10:42
作者:文/会员上传
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
MySQL 5.7.28 源码安装一、介绍:除了Oracle商业版数据库以外, MySQL是一款源代码开放的市面上使用率最高高的RDBMS数据库软件,采用的是GPL开源协议,自己是可以修改MySQL源代码用
以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。
除了Oracle商业版数据库以外, MySQL是一款源代码开放的市面上使用率最高高的RDBMS数据库软件,采用的是GPL开源协议,自己是可以修改MySQL源代码用来开发自己的系统。同样也是通过最常用的SQL语句进行管理
MySQL 安装方式通常分为以下三种:
l 在线Yum安装
l 离线rpm安装
l 源码编译安装
二、安装前环境清理:前面两种安装方式都非常简单,但是所有安装方式都共同需要遵顼以下安装前的步骤:
1) 检查是否有正在运行的MySQL进程[root@open_source~]#ps-ef|grepmysql|grep-vgrep2) 检查是否有正在运行的MySQL服务
6.x之前
[root@open_source~]#chkconfig--list|grepmysql
7.x之后
[root@open_source~]#ls-rtl/etc/init.d/mysqld[root@open_source~]#systemctlstatusmysql3) 检查和删除是否有系统自带的Mysql或mariadb
[root@open_source~]#rpm-qamysql[root@open_source~]#rpm-qamariadb三、MySQL软件下载:
https://downloads.mysql.com/archives/community/
四、开始安装 4.1 环境准备l 安装libaio-devel依赖包
[root@open_source~]#yuminstall-ylibaio-devel4.2 创建用户及目录
l 创建用户
[root@open_source~]#useradd-gmysqlmysql
l 创建目录
[root@open_source~]#mkdir/mysql/3306/data
l 赋权
[root@open_source~]#chown-Rmysql.mysql/mysql
4.3 开始安装
l解压软件
[root@open_source~]#cd/usr/local/[root@open_sourcelocal]#tarzxfmysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
l创建一个软连接并赋权
[root@open_sourcelocal]#ln-smysql-5.7.28-linux-glibc2.12-x86_64mysql[root@open_sourcelocal]#chown-Rmysql.mysqlmysql/
l配置环境变量
[root@open_sourcelocal]#echo"exportPATH=/usr/local/mysql/bin:$PATH"/etc/profile[root@open_sourcelocal]#source/etc/profile
l初始化数据库
[root@open_sourcelocal]#mysqld-initialize-insecure--user=mysql--basedir=/usr/local/mysql--datadir=/mysql/3306/data/
l配置My.cnf 文件
cat>/etc/my.cnf<<EOF[mysqld]user=mysqlbasedir=/usr/local/mysqldatadir=/mysql/3306/datalog_bin=/mysql/3306/binlog/mysql-binserver_id=7port=3306explicit_defaults_for_timestamp=truesocket=/tmp/mysql.sock[mysql]socket=/tmp/mysql.sockEOF
l准备启动脚本
[root@open_source~]#cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld
l启动数据库
[root@open_source~]#/etc/init.d/mysqldstart
l登录数据库
[root@open_source~]#mysqlWelcometotheMySQLmonitor.Commandsendwith;or\g.YourMySQLconnectionidis29Serverversion:5.7.28-logMySQLCommunityServer(GPL)Copyright(c)2000,2019,Oracleand/oritsaffiliates.Allrightsreserved.OracleisaregisteredtrademarkofOracleCorporationand/oritsaffiliates.Othernamesmaybetrademarksoftheirrespectiveowners.Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.mysql>
l MySQL加固:
[root@open_source~]#/usr/local/mysql/bin/mysql_secure_installationSecuringtheMySQLserverdeployment.ConnectingtoMySQLusingablankpassword.VALIDATEPASSWORDPLUGINcanbeusedtotestpasswordsandimprovesecurity.Itchecksthestrengthofpasswordandallowstheuserstosetonlythosepasswordswhicharesecureenough.WouldyouliketosetupVALIDATEPASSWORDplugin?Pressy|YforYes,anyotherkeyforNo:yTherearethreelevelsofpasswordvalidationpolicy:LOWLength>=8MEDIUMLength>=8,numeric,mixedcase,andspecialcharactersSTRONGLength>=8,numeric,mixedcase,specialcharactersanddictionaryfilePleaseenter0=LOW,1=MEDIUMand2=STRONG:0Pleasesetthepasswordforroothere.Newpassword:Re-enternewpassword:Estimatedstrengthofthepassword:50Doyouwishtocontinuewiththepasswordprovided?(Pressy|YforYes,anyotherkeyforNo):yBydefault,aMySQLinstallationhasananonymoususer,allowinganyonetologintoMySQLwithouthavingtohaveauseraccountcreatedforthem.Thisisintendedonlyfortesting,andtomaketheinstallationgoabitsmoother.Youshouldremovethembeforemovingintoaproductionenvironment.Removeanonymoususers?(Pressy|YforYes,anyotherkeyforNo):ySuccess.Normally,rootshouldonlybeallowedtoconnectfrom'localhost'.Thisensuresthatsomeonecannotguessattherootpasswordfromthenetwork.Disallowrootloginremotely?(Pressy|YforYes,anyotherkeyforNo):ySuccess.Bydefault,MySQLcomeswithadatabasenamed'test'thatanyonecanaccess.Thisisalsointendedonlyfortesting,andshouldberemovedbeforemovingintoaproductionenvironment.Removetestdatabaseandaccesstoit?(Pressy|YforYes,anyotherkeyforNo):y-Droppingtestdatabase...Success.-Removingprivilegesontestdatabase...Success.Reloadingtheprivilegetableswillensurethatallchangesmadesofarwilltakeeffectimmediately.Reloadprivilegetablesnow?(Pressy|YforYes,anyotherkeyforNo):ySuccess.Alldone!
l 加固后无法直接登录
[root@open_source~]#mysqlERROR1045(28000):Accessdeniedforuser'root'@'localhost'(usingpassword:NO)
l 查看MySQL状态
mysql>mysql>showmasterstatus;+------------------+----------+--------------+------------------+-------------------------------------------+|File|Position|Binlog_Do_DB|Binlog_Ignore_DB|Executed_Gtid_Set|+------------------+----------+--------------+------------------+-------------------------------------------+|mysql-bin.000009|3672|||ce8fc1bb-5fd6-11ea-869d-000c29eed638:1-20|+------------------+----------+--------------+------------------+-------------------------------------------+1rowinset(0.00sec)mysql>showdatabases;+--------------------+|Database|+--------------------+|information_schema||bindb||gtdb||mdp||mysql||performance_schema||sys||woo|+--------------------+8rowsinset(0.00sec)
11-20
11-19
11-20
11-20
11-20
11-19
11-20
11-20
11-19
11-20
11-19
11-19
11-19
11-19
11-19
11-19