1linux的常用软件安装 配置阿里云的yum源 1)安装wget〔rootlocalhost〕yumyinstallwget 2)下载yum源的配置文件〔rootlocalhost〕wgethttp:mirrors。aliyun。comrepoCentos7。repo 3)替换原有的yum源〔rootlocalhost〕mvetcyum。repos。dCentOSBase。repo备份原有的到root的家目录〔rootlocalhost〕mvCentos7。repoetcyum。repos。dCentOSBase。repo将下载的yum配置文件放在系统的指定目录 4)更新现有yum〔rootlocalhost〕yumcleanallyummakecacheyumyupdate 5)安装常用软件〔rootlocalhost〕yumyinstallopensshservervimgccgcccglibcheadersbzip2devellzodevelcurllrzszopensshclientszlibzlibdevelmakeautoconfautomakecmakelibtoolopensslopenssldevelfusedevelsnappydeveltelnetunzipzipnettools。x8664firewalldsystemdntp 2linux的JDK安装 此处我们选用jdk1。8144这个版本作为我们的基础JDK,此处要切记一点的是1。8的不同版本JDK在配置上会有很大的出入,所以请不要随便更换基础的JDK版本,否则你会很尴尬! 使用rz上传jdk到root的家目录〔rootlocalhost〕rz 使用rpm命令安装jdk〔rootlocalhost〕rpmivhjdk8u144linuxx64。rpm 配置jdk的环境变量〔rootlocalhost〕vietcprofileexportJAVAHOMEusrjavajdk1。8。0144exportJREHOMEJAVAHOMEjreexportPATHPATH:JAVAHOMEbinexportCLASSPATH。:JAVAHOMElibdt。jar:JAVAHOMElibtools。jar 刷新环境变量〔rootlocalhost〕sourceetcprofile〔rootlocalhost〕echoPATHusrlocalsbin:usrlocalbin:usrsbin:usrbin:rootbin:usrjavajdk1。8。0144bin〔rootlocalhost〕javaversionjavaversion1。8。0144Java(TM)SERuntimeEnvironment(build1。8。0144b01)JavaHotSpot(TM)64BitServerVM(build25。144b01,mixedmode) 到此JDK安装完成 3安装MySQL前说明 本例安装MySQL版本是5。7 4linux在线安装MySQL 用root用户安装 1)获取mysql源安装包 wgethttps:dev。mysql。comgetmysql57communityreleaseel711。noarch。rpm 2)安装mysql源 rpmivhmysql57communityreleaseel711。noarch。rpm 3)检查mysql源是否安装成功 yumrepolistenabledgrepmysql。community。 3)用yum命令安装mysql yuminstallmysqlcommunityserver 4)修改mysql的配置文件 查看MYSQL配置文件加载顺序:mysqldhelpverbosegrepA1B1cnf 修改etcmy。cnf配置文件内的文件目录 datadirdatamysqldata sqlmodeSTRICTTRANSTABLES,NOAUTOCREATEUSER,NOENGINESUBSTITUTION logerrordatamysqllogmysqld。log 其中: SQLMODE:通过对其正确的设置可以完成一些约束检查的工作,设置时,在配置文件my。cnf中配置进行全局的设置。 STRICTTRANSTALES(严格模式): 只对支持事务的表启用严格模式。 NOAUTOCREATEUSER: 禁止GRANT创建密码为空的用户。 NOENGINESUBSTITUTION: 启用后,若需要的存储引擎被禁用或未编译,则抛出错误;未启用时将用默认的存储引擎代替,并抛出一个异常。 5)创建mysql文件目录〔rootlocalhostjar〕mkdirpdatamysqldata〔rootlocalhostjar〕mkdirpdatamysqllog 6)生成首次登录随机密码mysqldinitialize 通过上面命令会在datamysqllogmysqld。log中生成随机码,随机码用来首次登录mysql。 7)修改mysql文件目录所有者为mysql用户chownRmysql:mysqldatamysql 8)启动mysqlsystemctlstartmysqld。service 9)关闭并重启mysql(可选)systemctlstopmysqld。servicesystemctlstartmysqld。service 如果再次启动报错,就重启Linux系统。 10)用生成的随机密码登录mysqlmysqlurootpujkq04yMD 登录后进入mysql命令行 11)修改ROOT用户密码setpasswordPASSWORD(12345678); 设置完密码后,需要用新密码重新登录 12)卸载mysql(不是必须的) 如果启动报错,根据错误查看原因,如果实在解决不了,卸载mysql重新装。 查看已经安装过的组件 rpmqagrepimysql 用yumyremove卸载所有mysqlyumyremovemysql57communityreleaseel711。noarchyumyremovemysqlcommunitycommon5。7。191。el7。x8664 卸载后再用rpmqagrepimysql查看,直至全部卸载 删除datamysql目录rmrfdatamysql 5linux离线安装MySQL 1)卸载CentOS7系统自带mariadb查看系统自带的Mariadb〔rootlocalhost〕rpmqagrepmariadbmariadblibs5。5。641。el7。x8664卸载系统自带的Mariadb〔rootlocalhost〕rpmenodepsmariadblibs5。5。641。el7。x8664删除etc目录下的my。cnf(如果有就删除,可以执行试一下,没有会提示你的)〔rootlocalhost〕rmetcmy。cnf 2)检查mysql是否存在检查是否已经安装〔rootlocalhost〕rpmqagrepmysql如果什么都没有返回空的说明啥也没安可以继续安装 3)检查mysql的用户和组是否存在如果不存在就创建检查有没有mysql用户〔rootlocalhost〕catetcpasswdgrepmysql检查有没有mysql组〔rootlocalhost〕catetcgroupgrepmysql查询全部用户〔rootlocalhost〕catetcpasswdgrepvnologingrepvhaltgrepvshutdownawkF:{print1314}more如果不存在就创建mysql用户创建mysql用户组〔rootlocalhost〕groupaddmysql创建一个用户名为mysql的用户,并加入mysql用户组〔rootlocalhost〕useraddgmysqlmysql设置mysql的密码000000〔rootlocalhost〕passwdmysql更改用户mysql的密码。新的密码:无效的密码:密码是一个回文重新输入新的密码:passwd:所有的身份验证令牌已经成功更新。 4)下载MySQL的离线安装包 官网下载地址:https:dev。mysql。comdownloadsmysql5。7。htmldownloads 版本选择,可以选择一下两种方式: 1)使用RedHatEnterpriseLinux SelectVersion:5。7。(因为更新的缘故具体细节版本可自行查看) SelectOperatingSystem:RedHatEnterpriseLinuxOracleLinux SelectOSVersion:RedHatEnterpriseLinux7OracleLinux7(x86,64bit) 列表中下载: CompressedTARArchive:(mysql5。7。25el7x8664。tar。gz)【本文中使用的是这个版本】 2)使用LinuxGeneric SelectVersion:5。7。(因为更新的缘故具体细节版本可自行查看) SelectOperatingSystem:LinuxGeneric SelectOSVersion:LinuxGeneric(glibc2。12)(x86,64bit) 列表中下载: CompressedTARArchive:(mysql5。7。25linuxglibc2。12x8664。tar。gz) 注意:上边两种方式找mysql离线安装包的方式都可以。 选完跳到以下这个页面点击下面的连接就可以开始下载了 5)上传MySQL的离线安装包并解压进行传统配置将mysql解压到usrlocal下〔rootlocalhostmysoft〕tarzxvfmysql5。7。29el7x8664。tar。gzCusrlocal创建软连接〔rootlocalhostlocal〕lnsmysql5。7。29el7x8664mysql修改目录与软件连的所属用户和组〔rootlocalhostlocal〕chownRmysql:mysqlmysql5。7。29el7x8664〔rootlocalhostlocal〕chownhmysql:mysqlmysql创建mysql的数据目录进入mysql(cdusrlocalmysql)〔rootlocalhostlocal〕cdmysql创建data目录〔rootlocalhostmysql〕mkdirdata目录赋权〔rootlocalhostmysql〕chownmysql:mysql。data 6)创建配置文件〔rootlocalhostlocal〕cdmysql〔rootlocalhostmysql〕vimmy。cnf(内容如下:)〔mysql〕socketvarlibmysqlmysql。socksetmysqlclientdefaultchararterdefaultcharactersetutf8〔mysqld〕socketvarlibmysqlmysql。socksetmysqlserverportport3306setmysqlinstallbasedirbasedirusrlocalmysqlsetthedatastoredirdatadirusrlocalmysqldatasetsqlmodesqlmodeSTRICTTRANSTABLES,NOAUTOCREATEUSER,NOENGINESUBSTITUTIONsetthenumberofallowmaxconnnectionmaxconnections200setservercharactredefaultencodingcharactersetserverutf8thestorageenginedefaultstorageengineINNODBlowercasetablenames1maxallowedpacket16Mexplicitdefaultsfortimestamptrue〔mysql。server〕usermysqlbasedirusrlocalmysql 7)开始安装MySQL〔rootlocalhostmysql〕cdusrlocalmysql〔rootlocalhostmysql〕binmysqlinstalldbusermysqlbasedirusrlocalmysqldatadirusrlocalmysqldata2020021215:14:15〔WARNING〕mysqlinstalldbisdeprecated。Pleaseconsiderswitchingtomysqldinitialize2020021215:14:20〔WARNING〕Thebootstraplogisntempty:2020021215:14:20〔WARNING〕20200212T07:14:16。103773Z0〔Warning〕bootstrapisdeprecated。Pleaseconsiderusinginitializeinstead20200212T07:14:16。104788Z0〔Warning〕Changedlimits:maxopenfiles:1024(requested5000)20200212T07:14:16。104795Z0〔Warning〕Changedlimits:tableopencache:431(requested2000) 设置权限〔rootlocalhostmysql〕cp。supportfilesmysql。serveretcinit。dmysqld〔rootlocalhostmysql〕chown777my。cnf〔rootlocalhostmysql〕chmodxetcinit。dmysqld 8)启动MySQL〔rootlocalhostmysql〕mkdirpvarlibmysql〔rootlocalhostmysql〕chownRmysql:mysqlvarlibmysql启动一次〔rootlocalhostmysql〕etcinit。dmysqldrestartERROR!MySQLserverPIDfilecouldnotbefound!StartingMySQL。Loggingtousrlocalmysqldatalocalhost。localdomain。err。SUCCESS!再启动一次〔rootlocalhostmysql〕etcinit。dmysqldrestartShuttingdownMySQL。。SUCCESS!StartingMySQL。SUCCESS! 9)设置开机启动〔rootlocalhostmysql〕chkconfiglevel35mysqldon〔rootlocalhostmysql〕chkconfiglistmysqld注:该输出结果只显示SysV服务,并不包含原生systemd服务。SysV配置数据可能被原生systemd配置覆盖。要列出systemd服务,请执行systemctllistunitfiles。查看在具体target启用的服务请执行systemctllistdependencies〔target〕。mysqld0:关1:关2:开3:开4:开5:开6:关〔rootlocalhostmysql〕chmodxetcrc。dinit。dmysqld〔rootlocalhostmysql〕chkconfigaddmysqld〔rootlocalhostmysql〕chkconfiglistmysqld注:该输出结果只显示SysV服务,并不包含原生systemd服务。SysV配置数据可能被原生systemd配置覆盖。要列出systemd服务,请执行systemctllistunitfiles。查看在具体target启用的服务请执行systemctllistdependencies〔target〕。mysqld0:关1:关2:开3:开4:开5:开6:关〔rootlocalhostmysql〕servicemysqldstatusSUCCESS!MySQLrunning(60791) 10)修改配置文件〔rootlocalhostmysql〕vimetcprofile添加一行exportPATHPATH:usrlocalmysqlbin〔rootlocalhostmysql〕sourceetcprofile 11)获取初始密码 获取初始密码〔rootlocalhostmysql〕catroot。mysqlsecretPasswordsetforuserrootlocalhostat2020021215:14:15Qba3P)rft 创建软连接〔rootlocalhostmysql〕lnsvarlibmysqlmysql。socktmpmysql。sock 登录mysql〔rootlocalhosttmp〕mysqlurootpQba3P)rft 修改密码〔rootlocalhosttmp〕mysqlurootpQba3P)rftmysql:〔Warning〕Usingapasswordonthecommandlineinterfacecanbeinsecure。WelcometotheMySQLmonitor。Corg。YourMySQLconnectionidis2Serverversion:5。7。29Copyright(c)2000,2020,Oracleandoritsaffiliates。Allrightsreserved。OracleisaregisteredtrademarkofOracleCorporationandoritsaffiliates。Othernamesmaybetrademarksoftheirrespectiveowners。Torhforhelp。Typectoclearthecurrentinputstatement。mysqlsetPASSWORDPASSWORD(000000);QueryOK,0rowsaffected,1warning(0。00sec) 检验密码是否成功mysqlexitBye〔rootlocalhosttmp〕mysqlurootp000000mysql:〔Warning〕Usingapasswordonthecommandlineinterfacecanbeinsecure。WelcometotheMySQLmonitor。Corg。YourMySQLconnectionidis3Serverversion:5。7。29MySQLCommunityServer(GPL)Copyright(c)2000,2020,Oracleandoritsaffiliates。Allrightsreserved。OracleisaregisteredtrademarkofOracleCorporationandoritsaffiliates。Othernamesmaybetrademarksoftheirrespectiveowners。Torhforhelp。Typectoclearthecurrentinputstatement。mysql 设置远程访问〔rootlocalhosttmp〕mysqlurootp000000mysql:〔Warning〕Usingapasswordonthecommandlineinterfacecanbeinsecure。WelcometotheMySQLmonitor。Corg。YourMySQLconnectionidis3Serverversion:5。7。29MySQLCommunityServer(GPL)Copyright(c)2000,2020,Oracleandoritsaffiliates。Allrightsreserved。OracleisaregisteredtrademarkofOracleCorporationandoritsaffiliates。Othernamesmaybetrademarksoftheirrespectiveowners。Torhforhelp。Typectoclearthecurrentinputstatement。mysqlgrantallprivilegeson。torootidentifiedby000000;QueryOK,0rowsaffected,1warning(0。00sec)mysqlgrantallprivilegeson。torootlocalhostidentifiedby000000;QueryOK,0rowsaffected,1warning(0。00sec)QueryOK,0rowsaffected(0。00sec) 海汼部落原创文章,原文链接:(http:hainiubl。comtopics75580)