美文网首页
linux安装最新版MySQL详细教程

linux安装最新版MySQL详细教程

作者: 哆啦在这A梦在哪 | 来源:发表于2020-03-27 14:18 被阅读0次

    linux安装最新版MySQL详细教程

    服务器环境是centos 7.6 这篇教程是通过yum方式安装的。

    安装依赖

    <pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">yum install libaio wget -y</pre>

    检查MYSQL是否已安装

    <pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">yum list installed | grep mysql</pre>

    image

    如果有先卸载

    <pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"># 格式 yum -y remove [包名]
    yum -y remove mysql-libs.x86_64</pre>

    下载MySQL官网的仓库文件

    <pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">cd /tmp wget http://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm

    yum localinstall mysql80-community-release-el7-1.noarch.rpm</pre>

    验证仓库是否添加成功

    <pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">yum repolist enabled | grep "mysql.-community."</pre>

    image

    安装MySQL

    <pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">yum install mysql-community-server -y</pre>

    image

    此时MySQL 安装完成,它包含了

    mysql-community-server、mysql-community-client
    mysql-community-common、mysql-community-libs 四个包

    执行

    <pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">rpm -qi mysql-community-server.x86_64 0:8.0.16-2.el7</pre>

    然后

    <pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">whereis mysql</pre>

    可以看到MySQL 的安装目录是 /usr/bin/

    启动服务

    <pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">systemctl start mysqld

    systemctl enable mysqld

    systemctl status mysqld</pre>

    查找初始密码

    <pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">cat /var/log/mysqld.log | grep password</pre>

    image

    这里可以看到初始密码

    进入mysql

    <pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">mysql -uroot -p</pre>

    修改初始密码

    <pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '你的密码';</pre>

    设置允许远程连接(新版MySQL的方式跟之前的不大一样)

    [ 复制代码

    ](javascript:void(0); "复制代码")

    <pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">mysql> use mysql;

    mysql> select host,user,authentication_string,plugin from user;

    mysql> update user set host='%' where user='root';

    mysql> flush privileges;</pre>

    [ 复制代码

    ](javascript:void(0); "复制代码")

    查看字符编码

    <pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">mysql> status</pre>

    如果是【utf8mb4】那就不用改了

    接下来就可以通过navicat进行连接了

    image

    安装成功!

    相关文章

      网友评论

          本文标题:linux安装最新版MySQL详细教程

          本文链接:https://www.haomeiwen.com/subject/fupluhtx.html