centos 6.5下 mysql-community-server. 5.7.18-1.el6安装
使用下面的命令检查是否安装有MySQLServer
[root@localhostetc]#rpm-qa|grepmysql//这个命令就会查看该操作系统上是否已经安装了mysql数据库
有的话,我们就通过rpm-e命令或者rpm-e--nodeps命令来卸载掉
[root@localhost~]#rpm-emysql//普通删除模式 [root@localhost~]#rpm-e--nodepsmysql//强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除
在删除完以后我们可以通过rpm-qa|grepmysql命令来查看mysql是否已经卸载成功!!
官网yumrepository下载安装包
[root@localhost~]#wgethttp://dev.mysql.com/get/mysql57-community-release-el6-10.noarch.rpm --2017-04-2418:53:49--http://dev.mysql.com/get/mysql57-community-release-el6-10.noarch.rpm Resolvingdev.mysql.com...137.254.60.11 Connectingtodev.mysql.com|137.254.60.11|:80...connected. HTTPrequestsent,awaitingresponse...301MovedPermanently Location:https://dev.mysql.com/get/mysql57-community-release-el6-10.noarch.rpm[following] --2017-04-2418:53:49--https://dev.mysql.com/get/mysql57-community-release-el6-10.noarch.rpm Connectingtodev.mysql.com|137.254.60.11|:443...connected. ERROR:certificatecommonname“www.mysql.com”doesn'tmatchrequestedhostname“dev.mysql.com”. Toconnecttodev.mysql.cominsecurely,use‘--no-check-certificate'
本地安装下载下来的rpm包
[root@localhost~]#yumlocalinstallmysql57-community-release-el6-10.noarch.rpm Loadedplugins:fastestmirror,refresh-packagekit,security SettingupLocalPackageProcess Examiningmysql57-community-release-el6-10.noarch.rpm:mysql57-community-release-el6-10.noarch Markingmysql57-community-release-el6-10.noarch.rpmtobeinstalled Loadingmirrorspeedsfromcachedhostfile *base:mirrors.cn99.com *extras:mirrors.cn99.com *updates:mirrors.cn99.com ResolvingDependencies -->Runningtransactioncheck --->Packagemysql57-community-release.noarch0:el6-10willbeinstalled -->FinishedDependencyResolution DependenciesResolved =============================================================================================================================================================================================== PackageArchVersionRepositorySize =============================================================================================================================================================================================== Installing: mysql57-community-releasenoarchel6-10/mysql57-community-release-el6-10.noarch30k TransactionSummary =============================================================================================================================================================================================== Install1Package(s) Totalsize:30k Installedsize:30k Isthisok[y/N]:y DownloadingPackages: Runningrpm_check_debug RunningTransactionTest TransactionTestSucceeded RunningTransaction Installing:mysql57-community-release-el6-10.noarch1/1 Verifying:mysql57-community-release-el6-10.noarch1/1 Installed: mysql57-community-release.noarch0:el6-10 Complete!
查看可用的安装包
[root@localhost~]#yumrepolistenabled|grepmysql mysql-connectors-communityMySQLConnectorsCommunity33 mysql-tools-communityMySQLToolsCommunity47 mysql57-communityMySQL5.7CommunityServer183
安装前装gcc所有包,防止报错[Errno-1] Packagedoesnotmatchintendeddownload
[root@localhostyum.repos.d]#yuminstallgcc*
安装mysql
[root@localhostyum.repos.d]#yuminstall-ymysql-community-server Loadedplugins:fastestmirror,refresh-packagekit,security Loadingmirrorspeedsfromcachedhostfile *base:mirrors.cn99.com *extras:mirrors.cn99.com *updates:mirrors.cn99.com SettingupInstallProcess ResolvingDependencies -->Runningtransactioncheck --->Packagemysql-community-server.x86_640:5.7.18-1.el6willbeinstalled -->ProcessingDependency:mysql-community-common(x86-64)=5.7.18-1.el6forpackage:mysql-community-server-5.7.18-1.el6.x86_64 -->ProcessingDependency:mysql-community-client(x86-64)>=5.7.9forpackage:mysql-community-server-5.7.18-1.el6.x86_64 -->Runningtransactioncheck --->Packagemysql-community-client.x86_640:5.7.18-1.el6willbeinstalled -->ProcessingDependency:mysql-community-libs(x86-64)>=5.7.9forpackage:mysql-community-client-5.7.18-1.el6.x86_64 --->Packagemysql-community-common.x86_640:5.7.18-1.el6willbeinstalled -->Runningtransactioncheck --->Packagemysql-community-libs.x86_640:5.7.18-1.el6willbeobsoleting --->Packagemysql-libs.x86_640:5.1.71-1.el6willbeobsoleted -->ProcessingDependency:libmysqlclient.so.16()(64bit)forpackage:2:postfix-2.6.6-2.2.el6_1.x86_64 -->ProcessingDependency:libmysqlclient.so.16(libmysqlclient_16)(64bit)forpackage:2:postfix-2.6.6-2.2.el6_1.x86_64 -->Runningtransactioncheck --->Packagemysql-community-libs-compat.x86_640:5.7.18-1.el6willbeobsoleting --->Packagepostfix.x86_642:2.6.6-2.2.el6_1willbeupdated --->Packagepostfix.x86_642:2.6.6-8.el6willbeanupdate -->FinishedDependencyResolution DependenciesResolved ============================================================================================================================= PackageArchVersionRepositorySize ============================================================================================================================= Installing: mysql-community-libsx86_645.7.18-1.el6mysql57-community2.1M replacingmysql-libs.x86_645.1.71-1.el6 mysql-community-libs-compatx86_645.7.18-1.el6mysql57-community1.6M replacingmysql-libs.x86_645.1.71-1.el6 mysql-community-serverx86_645.7.18-1.el6mysql57-community152M Installingfordependencies: mysql-community-clientx86_645.7.18-1.el6mysql57-community23M mysql-community-commonx86_645.7.18-1.el6mysql57-community328k Updatingfordependencies: postfixx86_642:2.6.6-8.el6base2.0M TransactionSummary ============================================================================================================================= Install5Package(s) Upgrade1Package(s) Totalsize:180M Totaldownloadsize:152M DownloadingPackages: mysql-community-server-5.7.18-1.el6.x86_64.rpm|152MB01:41 warning:rpmts_HdrFromFdno:HeaderV3DSA/SHA1Signature,keyID5072e1f5:NOKEY Retrievingkeyfromfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql ImportingGPGkey0x5072E1F5: Userid:MySQLReleaseEngineeringPackage:mysql57-community-release-el6-10.noarch(@/mysql57-community-release-el6-10.noarch) From:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql Runningrpm_check_debug RunningTransactionTest TransactionTestSucceeded RunningTransaction Installing:mysql-community-common-5.7.18-1.el6.x86_641/8 Installing:mysql-community-libs-5.7.18-1.el6.x86_642/8 Installing:mysql-community-libs-compat-5.7.18-1.el6.x86_643/8 Installing:mysql-community-client-5.7.18-1.el6.x86_644/8 Installing:mysql-community-server-5.7.18-1.el6.x86_645/8 Updating:2:postfix-2.6.6-8.el6.x86_646/8 Cleanup:2:postfix-2.6.6-2.2.el6_1.x86_647/8 Erasing:mysql-libs-5.1.71-1.el6.x86_648/8 Verifying:2:postfix-2.6.6-8.el6.x86_641/8 Verifying:mysql-community-libs-compat-5.7.18-1.el6.x86_642/8 Verifying:mysql-community-server-5.7.18-1.el6.x86_643/8 Verifying:mysql-community-libs-5.7.18-1.el6.x86_644/8 Verifying:mysql-community-common-5.7.18-1.el6.x86_645/8 Verifying:mysql-community-client-5.7.18-1.el6.x86_646/8 Verifying:2:postfix-2.6.6-2.2.el6_1.x86_647/8 Verifying:mysql-libs-5.1.71-1.el6.x86_648/8 Installed: mysql-community-libs.x86_640:5.7.18-1.el6mysql-community-libs-compat.x86_640:5.7.18-1.el6 mysql-community-server.x86_640:5.7.18-1.el6 DependencyInstalled: mysql-community-client.x86_640:5.7.18-1.el6mysql-community-common.x86_640:5.7.18-1.el6 DependencyUpdated: postfix.x86_642:2.6.6-8.el6 Replaced: mysql-libs.x86_640:5.1.71-1.el6 Complete!
启动mysql
[root@localhostyum.repos.d]#servicemysqldstart InitializingMySQLdatabase:[OK] Installingvalidatepasswordplugin:[OK] Startingmysqld:
进入mysql安全模式
[root@localhostyum.repos.d]#killall-TERMmysqld [root@localhostyum.repos.d]#mysqld_safe--skip-grant-tables& [1]40422 [root@localhostyum.repos.d]#2017-04-25T07:45:39.222061Zmysqld_safeLoggingto'/var/log/mysqld.log'. 2017-04-25T07:45:39.246117Zmysqld_safeStartingmysqlddaemonwithdatabasesfrom/var/lib/mysql mysql-uroot-p Enterpassword: WelcometotheMySQLmonitor.Commandsendwith;or\g. YourMySQLconnectionidis3 Serverversion:5.7.18MySQLCommunityServer(GPL) Copyright(c)2000,2017,Oracleand/oritsaffiliates.Allrightsreserved. OracleisaregisteredtrademarkofOracleCorporationand/orits affiliates.Othernamesmaybetrademarksoftheirrespective owners. Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement. mysql>usemysql Readingtableinformationforcompletionoftableandcolumnnames Youcanturnoffthisfeaturetogetaquickerstartupwith-A Databasechanged mysql>select*fromusers; ERROR1146(42S02):Table'mysql.users'doesn'texist mysql>select*fromuser; mysql>updateusersetauthentication_string=PASSWORD('mysql')whereuser='root'; QueryOK,1rowaffected,1warning(0.00sec) Rowsmatched:1Changed:1Warnings:1 mysql>quit Bye [2]+Exit1mysqld_safe--skip-grant-tables [root@localhostyum.repos.d]#servicemysqldstart Startingmysqld:[OK] [root@localhostyum.repos.d]#mysql-uroot-p Enterpassword: WelcometotheMySQLmonitor.Commandsendwith;or\g. YourMySQLconnectionidis5 Serverversion:5.7.18MySQLCommunityServer(GPL) Copyright(c)2000,2017,Oracleand/oritsaffiliates.Allrightsreserved. OracleisaregisteredtrademarkofOracleCorporationand/orits affiliates.Othernamesmaybetrademarksoftheirrespective owners. Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.
mysql-h主机地址-u用户名-p用户密码
1、例1:连接到本机上的MYSQL
找到mysql的安装目录,一般可以直接键入命令mysql-uroot-p,回车后提示你输密码,如果刚安装好MYSQL,超级用户root是没有密码的,故直接回车即可进入到MYSQL中
了,MYSQL的提示符是:mysql>
2、连接到远程主机上的MYSQL
假设远程主机的IP为:10.0.0.1,用户名为root,密码为123。则键入以下命令:
mysql-h10.0.0.1-uroot-p123
(注:u与root可以不用加空格,其它也一样)
配置防火墙
防火墙的3306端口默认没有开启,若要远程访问,需要开启这个端口
打开/etc/sysconfig/iptables
在“-AINPUT–mstate--stateNEW–mtcp–ptcp–dport22–jACCEPT”,下添加:
-AINPUT-mstate--stateNEW-mtcp-ptcp--dport3306-jACCEPT
然后保存,并关闭该文件,在终端内运行下面的命令,刷新防火墙配置:
serviceiptablesrestartOK,一切配置完毕,你可以访问你的MySQL了~
注意:增加的开放3306端口的语句一定要在icmp-host-prohibited之前
mysql-uroot-p Enterpassword: WelcometotheMySQLmonitor.Commandsendwith;or\g. YourMySQLconnectionidis3 Serverversion:5.7.18MySQLCommunityServer(GPL)
Copyright(c)2000,2017,Oracleand/oritsaffiliates.Allrightsreserved.
OracleisaregisteredtrademarkofOracleCorporationand/orits
affiliates.Othernamesmaybetrademarksoftheirrespective
owners.
Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.
以上所述是小编给大家介绍的centos6.5下mysql-community-server.5.7.18-1.el6安装,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!