Centos7 Mysql5.7.27二进制安装

步骤一:下载安装包,打开Mysql官网,找到对应的

下载路径如下:https://downloads.mysql.com/archives/community/

wget https://downloads.mysql.com/archives/get/file/mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz  -O /usr/local/src/mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz

步骤二:下载依赖包,Centos7自带不需要安装

[[email protected] 21:56:19]:/usr/local/src
#yum -y install libaio
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
软件包 libaio-0.3.109-13.el7.x86_64 已安装并且是最新版本
无须任何处理

步骤三:解压安装包

[[email protected] 21:58:45]:/usr/local/src
#tar -zxvf mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz 

步骤四:创建数据库用户,移动数据库文件到你想要放的位置,并创建mysql数据目录,最后修改属主为Mysql

[[email protected] 21:59:26]:/usr/local/src
#useradd -M -s /sbin/nologin -r mysql#mv /usr/local/src/mysql-5.7.27-linux-glibc2.12-x86_64 /home/data/mysql
[[email protected] 22:02:09]:/usr/local/src
#mkdir -p /home/data/mysql
[[email protected] 22:02:18]:/usr/local/src
#chown -R mysql.mysql /home/data/mysql

步骤五:初始化数据库

[[email protected] 22:04:56]:/home/data
#/home/data/mysql/bin/mysqld --initialize --user=mysql --basedir=/home/data/mysql --datadir=/home/data/mysql/data
2019-11-09T14:06:56.634380Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-11-09T14:06:57.063698Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-11-09T14:06:57.142365Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-11-09T14:06:57.200813Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 30cc7a37-02fa-11ea-a548-000c29cbc202.
2019-11-09T14:06:57.202254Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.
2019-11-09T14:06:57.203612Z 1 [Note] A temporary password is generated for [email protected]: KaELVb2yol<4 #此次是生成的临时密码,用于第一次登陆,登陆后需要重新修改

步骤六:创建配置文件,这里只创建常见配置文件

cat > /etc/my.cnf <<EOF
[mysqld]
basedir=/home/data/mysql
datadir=/home/data/mysql/data
port=3306
socket=/home/data/mysql/mysql.sock
character-set-server=utf8
log-error=/var/log/mysqld.log
pid-file=/tmp/mysqld.pid
[mysql]
socket=/home/data/mysql/mysql.sock
[client]
socket=/home/data/mysql/mysql.sock
EOF

步骤七:配置环境变量,并刷新

cat >/etc/profile.d/mysql.sh <<EOF
export PATH=/home/data/mysql/bin:\$PATH
EOFsource /etc/profile.d/mysql.sh 

步骤八:生成启动脚本,并启动mysql

[[email protected] 22:14:40]:/home/data
#cp /home/data/mysql/support-files/mysql.server /etc/init.d/mysql
[[email protected] 22:16:42]:/home/data
#chmod +x /etc/init.d/mysql[[email protected] 22:17:55]:/home/data
#vim /etc/init.d/mysql 
#修改mysql启动配置文件,指定datadir和basedir路径,如不指定,默认是/usr/local/mysql
[[email protected] 22:18:31]:/home/data
#sed -i ‘46s#basedir=#basedir=/home/data/mysql#‘ /etc/init.d/mysql
[[email protected] 22:20:15]:/home/data
#sed -n ‘46p‘ /etc/init.d/mysql
basedir=/home/data/mysql
[[email protected] 22:20:30]:/home/data
#sed -i ‘47s#datadir=#datadir=/home/data/mysql/data#‘ /etc/init.d/mysql
[[email protected] 22:21:13]:/home/data
#sed -n ‘47p‘ /etc/init.d/mysql
datadir=/home/data/mysql/data
#启动mysql
[[email protected] 22:23:54]:/home/data
# /etc/init.d/mysql start
Starting MySQL. SUCCESS! 

步骤九:登录mysql,并修改密码

[[email protected] 22:26:28]:/home/data
#mysql -uroot -p‘KaELVb2yol<4‘
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.27

Copyright (c) 2000, 2019, 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> set password for [email protected]=password(‘cnhope‘);
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

原文地址:https://www.cnblogs.com/cnhope/p/11828190.html

时间: 2024-10-08 17:46:00

Centos7 Mysql5.7.27二进制安装的相关文章

Centos7 MYSQL5.6.42二进制安装

1. 下载二进制mysql的安装包 [root@minion-1 ~]#wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.42-linux-glibc2.12-x86_64.tar.gz 2. 新建一个专放软件的目录 [root@minion-1 ~]#mkdir -p /services/current_apps 3. 解压包到放软件的目录下 [root@minion-1 ~]# tar -xzf mysql-5.6.42-linux

mysql5.6 通用二进制安装

mysql5.6 通用二进制安装: #卸载原有的mysqlyum remove mysql*ls /etc/my.cnf*mv /etc/my.cnf* /tmp/ #安装依赖包yum install make cmake gcc gcc-c++ bison-devel ncurses-devel autoconf automake -y #添加用户groupadd mysqluseradd -r -g mysql mysql#useradd -M -s /sbin/nologin mysql

mysql5.6.20二进制安装部署文档

一.业务需求: 单台服务器线上运行着mysql5.5.48 现在是不影响线上的业务,不停止线上的mysql5.5数据库来部署另外一个mysql5.6.20的实例 二.安装部署过程: 2.1安装部署过程注意事项: 在初始化mysql数据库时,是会寻找my.cnf配置文件的,是有顺序的,默认的顺序是: [[email protected] ~]# mysql --help | grep 'Default options' -A 1 Default options are read from the

mysql-5.7.20 二进制安装 | 备份恢复

###### 二进制自动安装数据库脚本root密码123456将脚本和安装包放在/usr/local/src目录即可############### ######数据库目录/usr/local/mysql############ ######数据目录/data/mysql############ ######慢日志目录/data/slowlog############ ######端口号默认3306其余参数按需自行修改############ #!/bin/bash cd /usr/local/s

mysql-5.6.x和mysql-5.7.x二进制安装

#!/bin/bash #__Author__:Allen_Jol at 2018-03-21 13:52:13 #Description: install mysql-5.6.39 or mysql-5.7.21 binary for centos 6.x CPUINFO=`cat /proc/cpuinfo | grep -c  processor` DIR="/usr/local/src" MDIR="/usr/local/mysql" DATADIR=&qu

mysql-5.7.21 二进制安装 | Jemalloc内存优化 | 备份恢复|修改密码

简介 ######数据库目录/usr/local/mysql############ ######数据目录/data/mysql############ ######慢日志目录/data/slowlog############ ######端口号默认3306其余参数按需自行修改############ 安装脚本 #!/bin/bash cd /usr/local/src/ if [ ! -f mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz ]; then w

mysql5.5.60二进制安装

系统centos6.8安装过程如下: mkdir -p /home/mysql3307/{data,log,binlog,tmp} useradd mysql -S /sbin/nologin -M chown -R mysql.mysql /home/mysql3307/{data,log,binlog,tmp} wget http://ftp.kaist.ac.kr/mysql/Downloads/MySQL-5.5/mysql-5.5.60-linux-glibc2.12-x86_64.t

mysql5.6.20二进制安装

1把105的/usr/local/mysql拷过去 2. 把105的/etc/my.cnf拷过去 3. mkdir /data/mysql/{data,tmp,binlog,log}-p 4. 初始化 rpm -qa mysql yum remove mysql-5.1.73-8.el6_8.x86_64 /etc/my.cnf /etc/my.cnf.bak yum install libaio* useradd mysql mkdir /data/mysql/{data,tmp,binlog

mysql5.7.22二进制安装

系统版本:centos6.5 内核:2.6第一步初始化: ./bin/mysqld --initialize --user=mysql --datadir=数据存放路径 --basedir=安装包路径第二步./bin/mysql_ssl_rsa_setup --datadir=数据存放路径第三部:./bin/mysqld --defaults-file=配置文件路径 --user=root第四步:(修改密码)set password = password('tongda666'); 注意:路径=