二进制免编译 MySQL 安装-5.7

一、了解 MySQL

MySQL是一个 关系型数据库管理系统 , 由瑞典MySQL AB 公司开发,属于 Oracle 旗下产品。 MySQL 是最流行的 关系型数据库管理系统 之一,在 WEB 应用方面,MySQL是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件之一。

二、下载 MySQL 安装包

官网:MySQL :: Download MySQL Community Server (Archived Versions)

 

 

三、配置 MySQL

hostname +主机名                                                 //修改主机名
bash                                    //保存为修改后的主机名

1.解压 MySQL

一般情况下软件安装包都放在 /opt 放入usr/local/mysql 更统一方便管理下面。我是把 MySQL 放到了 /usr/local目录下。

tar -zxf +解压文件名                                              //解压文件(f前面加v可以看解压过程)

红色文件是压缩包,蓝色的是解压完成文件

2.配置 MySQL

useradd -s /sbin/nologin mysql                                        //创建MySQL启动用户,不可登录
chown -R mysql:mysql +目录                                            //修改所属组和所属用户

执行正确后如下图。

yum install -y perl-Module-Install                                //下载 MySQL 依赖
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/      //启动 mysql_insrall_db 这个脚本 
  (前面的.是指当前目录、 --user=:指定用户、 --datadir=:指定安装目录、一定要在MySQL解压的这个文件下做 )
echo $?                                       //查看是否执行正确
cp +文件名 +路径                                   //复制到文件到那个目录下

配置文件第一步:

 

第二步:

chmod 777 +文件路径                                            //授权文件
chkconfig --add mysqld                                        //开机自启
chkconfig mysql on                                            //开机不自动启动
service mysqld start                                          //启动 MySQL
netstat -ntlp                              //查看端口

查看端口的时候有3306说明成功了。 

 

 现在就可以使用 MySQL 。 (看下面的代码这就是启动 MySQL 的区别)(如果不去修改环境变量那么每一次去使用 MySQL 得输入绝对地址)

[root@bogon init.d]# /usr/local/mysql/bin/mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.47 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> Bye
    -> 
    -> Ctrl-C -- exit!
Aborted

# 进入 /ect/profile 把这行代码写到文件最后面 PATH=$PATH:/usr/local/mysql/bin [root@bogon
~]# vim /etc/profile #刷新环境变量 [root@bogon ~]# source /etc/profile [root@bogon ~]# mysql -uroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.6.47 MySQL Community Server (GPL) Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> Ctrl-C -- exit! Aborted

 

posted @ 2021-09-17 22:52  花花de代码生活  阅读(87)  评论(0编辑  收藏  举报