• ADADADADAD

    如何在CentOS 6和CentOS7中安装mysql 5.7[ mysql数据库 ]

    mysql数据库 时间:2024-11-29 09:50:02

    作者:文/会员上传

    简介:

    Step1. 查看已安装的mysql:#yumlistinstalled|grepmysqlmysql-libs.x86_645.1.71-1.el6@anaconda-CentOS-201311272149.x86_64/6.5卸载当前mysql:#yum-yremovemysql-libs.x86_

    以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。

    Step1. 查看已安装的mysql:

    #yumlistinstalled|grepmysqlmysql-libs.x86_645.1.71-1.el6@anaconda-CentOS-201311272149.x86_64/6.5

    卸载当前mysql:

    #yum-yremovemysql-libs.x86_64

    Step2. 下载安装所需依赖:

    先到这里下载,根据自己Linux版本来选择,比如本人是Centos6.5,故选择第二个,依次类推:

    将下载的mysql80-community-release-el6-1.noarch.rpm文件上传到Linux服务器中

    Step3. 安装依赖:

    使用以下命令,注意此命令需要在mysql80-community-release-el6-1.noarch.rpm文件的所在目录下执行。

    执行过程中会出现Is this ok [y/N]: ,输入y就行了。

    #yumlocalinstallmysql80-community-release-el6-1.noarch.rpm

    执行完之后,使用# ls /etc/yum.repos.d命令可以看到多出来了两个文件

    #ls/etc/yum.repos.dmysql-community.repomysql-community-source.repo

    Step4. 运行yum repolist enabled | grep mysql查看mysql57是否可用。

    如果运行的结果如下:

    #yumrepolistenabled|grepmysqlmysql-connectors-communityMySQLConnectorsCommunity59mysql-tools-communityMySQLToolsCommunity65mysql80-communityMySQL8.0CommunityServer29

    则需要使用命令vim /etc/yum.repos.d/mysql-community.repo修改mysql57的enabled为1,而其他的版本则设为0.具体如下:

    vim/etc/yum.repos.d/mysql-community.repo

    修改部分:

    ......#EnabletouseMySQL5.7[mysql57-community]name=MySQL5.7CommunityServerbaseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql......[mysql80-community]name=MySQL8.0CommunityServerbaseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/6/$basearch/enabled=0gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

    设置完的运行结果为:

    #yumrepolistenabled|grepmysqlmysql-connectors-communityMySQLConnectorsCommunity59mysql-tools-communityMySQLToolsCommunity65mysql57-communityMySQL5.7CommunityServer273

    Step5. 开始安装:

    #yuminstallmysql-community-server

    如果中途出错停止,一般是因为网速原因,可以重复执行此命令

    Step6. 安装完成后,启动mysql服务(可能第一次会出错,那就再运行一次~):

    #servicemysqldstartInitializingMySQLdatabase:[FAILED]#servicemysqldstartStartingmysqld:[OK]

    Step7. 查看默认root用户的密码:

    #cat/var/log/mysqld.log|greproot@localhost2018-08-29T03:11:26.560863Z1[Note]Atemporarypasswordisgeneratedforroot@localhost:DJ#erA*-p6&?

    DJ#erA*-p6&? 即为root用户的初始密码

    Step8. 使用mysql -uroot -p命令登录,需要输入上一步中的密码。

    进入之后进行任何操作都会提示ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.这时需要重置密码:

    mysql>showdatabases;ERROR1820(HY000):YoumustresetyourpasswordusingALTERUSERstatementbeforeexecutingthisstatement.mysql>setpassword=password('new_password');QueryOK,0rowsaffected,1warning(0.01sec)mysql>alteruser'root'@'localhost'passwordexpirenever;QueryOK,0rowsaffected(0.00sec)mysql>flushprivileges;QueryOK,0rowsaffected(0.00sec)
    如何在CentOS 6和CentOS7中安装mysql 5.7.docx

    将本文的Word文档下载到电脑

    推荐度:

    下载