Linux(CentOS)环境下安装MySQL

    xiaoxiao2021-03-26  49

    本机需要连接互联网(后面实例是以在线安装为例)

    1、 在MySQL官网下载yum安装源( 保存到CentOS7.0系统路径(桌面\Software )) https://dev.mysql.com/downloads/repo/yum/ 下载名称:

    Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package

    1.      9.0K

    2.      Download

    (mysql57-community-release-el7-9.noarch.rpm)

    2、 添加下载的yum源(可用命令localinstall/install),进入文件夹Software,输入以下命令

    [root@localhost Software]# yum install -ymysql57-community-release-el7-9.noarch.rpm

    3、 安装MySQL(检查启用可安装程序组件)

    [root@localhost Software]# yum repolist all | grep mysql [root@localhost Software]# yum install -y mysql-community-server 4、 启动MySQL服务

    [root@localhost Software]# service mysqld start

    5、 查看root临时密码(右健上面复制密码“9j6srtfRp>;D”)

    [root@localhost Software]# grep "password"/var/log/mysqld.log

    2017-02-05T09:22:20.086699Z 1 [Note] A temporary passwordis generated for root@localhost: 9j6srtfRp>;D

    6、 测试连接

    5.1、连接MySQL(输入密码直接右健粘贴,回车健确认)

    [root@localhostSoftware]# mysql -u root -p

    Enter password: 9j6srtfRp>;D

    5.2、测试连接效果

    以下提示需要重置密码才能操作

    mysql>show databases -> ; ERROR 1820 (HY000): You must reset your password usingALTER USER statement before executing this statement. mysql>set password for 'root'@'localhost'=password('输入root新密码'); Query OK,0 rows affected, 1 warning (0.00 sec) mysql>use mysql; Readingtable information for completion of table and column names You canturn off this feature to get a quicker startup with -A Databasechanged mysql>show databases; +--------------------+ |Database | +--------------------+ |information_schema | |mysql | |performance_schema | |sys | +--------------------+ 4 rows in set (0.00 sec)

    --以上为测试成功连接效果

    转载请注明原文地址: https://ju.6miu.com/read-662446.html

    最新回复(0)