mysql5.18二进制安装

下载mysqld二进制包

[[email protected] ~]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
--2020-03-01 20:44:21--  https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
正在解析主机 downloads.mysql.com (downloads.mysql.com)... 137.254.60.14
正在连接 downloads.mysql.com (downloads.mysql.com)|137.254.60.14|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz [跟随至新的 URL]
--2020-03-01 20:44:28--  https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
正在解析主机 cdn.mysql.com (cdn.mysql.com)... 104.75.165.42
正在连接 cdn.mysql.com (cdn.mysql.com)|104.75.165.42|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:654430368 (624M) [application/x-tar-gz]
正在保存至: “mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz”

100%[=====================================================================================================================================================>] 654,430,368  522KB/s 用时 19m 39s 

2020-03-01 21:04:07 (542 KB/s) - 已保存 “mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz” [654430368/654430368])

 卸载mariadb或mysql系统自动安装的相关的包

[[email protected] ~]# rpm -qa | grep maradb| xargs -e --nodeps

解压移动指定目录,并重名mysql

[[email protected] ~]#  mv mysql-5.7.18-linux-glibc2.5-x86_64 /usr/local/mysql

  创建用户与组

[[email protected] ~]# groupadd mysql
[[email protected] ~]# useradd -r -g mysql mysql

  编写默认配置文件

cat > /etc/my.cnf <<EOF
[mysqld]
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
symbolic-links=0

[mysqld_safe]
log-error=/usr/local/mysql/logs/error.log
pid-file=/usr/local/mysql/mysql.pid

[client]
socket=/usr/local/mysql/mysql.sock
EOF

  创建数据目录,日志目录及文件,并授权修改用户属组

[[email protected] ~]# mkdir /usr/local/mysql/{data,logs}
[[email protected] ~]# touch /usr/local/mysql/logs/error.log
[[email protected] ~]#  chown mysql:mysql -R /usr/local/mysql

  初始化数据库

[[email protected] ~]# /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
2020-03-04T11:36:19.672944Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2020-03-04T11:36:24.605282Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-03-04T11:36:25.355978Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-03-04T11:36:25.413157Z 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: 615a0cd8-5e0c-11ea-
95be-000c29168707.2020-03-04T11:36:25.423186Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.
2020-03-04T11:36:25.433433Z 1 [Warning] [email protected] is created with an empty password ! Please consider switching off the --initialize-insecure option.

  安全加固操作

[[email protected] ~]# /usr/local/mysql/bin/mysql_ssl_rsa_setup --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
Generating a 2048 bit RSA private key
.........+++
....+++
writing new private key to ‘ca-key.pem‘
-----
Generating a 2048 bit RSA private key
........+++
..............................+++
writing new private key to ‘server-key.pem‘
-----
Generating a 2048 bit RSA private key
.........................................................................................................................+++
...............................................................................................................................................................................................
...........................+++writing new private key to ‘client-key.pem‘
-----

  拷贝启动脚本

[[email protected] ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

  修改启动脚本路径

[[email protected] ~]# sed -i ‘46c basedir=/usr/local/mysql‘ /etc/init.d/mysqld
[[email protected] ~]# sed -i ‘47c datadir=/usr/local/mysql/data‘ /etc/init.d/mysqld
[[email protected] ~]# sed -i ‘63c mysqld_pid_file_path=/usr/local/mysql/data/mysqld.pid‘ /etc/init.d/mysqld

  启动

[[email protected] ~]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS!

 修改密码

[[email protected] ~]# mysql -e "use mysql;alter user ‘root‘@‘localhost‘ identified by ‘123456‘;"

  登录

[[email protected] ~]# mysql -p123456
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 5
Server version: 5.7.18 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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> exit
Bye

  查看版本

[[email protected] ~]# mysql -uroot -p123456 -e "select version()"
mysql: [Warning] Using a password on the command line interface can be insecure.
+-----------+
| version() |
+-----------+
| 5.7.18    |
+-----------+

  

[[email protected] ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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> exit
Bye

  修改密码

[[email protected] ~]# mysql -e "use mysql;alter user ‘root‘@‘localhost‘ identified by ‘123456‘;"

  登录

[[email protected] ~]# mysql -p123456
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 5
Server version: 5.7.18 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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>

  设置启动脚本

#Before=shutdown.target # 关机前操作
#User=mysql # 此用户必须存在,即为启动mysql的用户
cat > /usr/lib/systemd/system/mysqld.service  <<EOF
[mysqld]
[Unit]
Description=MySQL
SourcePath=/etc/init.d/mysqld
Before=shutdown.target

[Service]
User=mysql
Type=forking
ExecStart=/etc/init.d/mysqld start
ExecStop=/etc/init.d/mysqld stop

[Install]
WantedBy=multi-user.target
EOF

  重读文件

[email protected] ~]# systemctl daemon-reload
[[email protected] ~]# systemctl restart   mysqld

  

 

原文地址:https://www.cnblogs.com/rdchenxi/p/12416660.html

时间: 2024-10-26 04:21:36

mysql5.18二进制安装的相关文章

mysql5.6二进制安装

mysql服务器安装在linux居多,网上有很多种方法,本人推荐用用二进制.理由如下: 1,二进制安装安装方便. 2,oralce制定的在二进制包优化方面也是很优秀的,而大多数dba对GCC编译了解也不是很深,编译源码并不一定会比二进制好. 3,二进制有一定的对比性方便排查问题,源码添加的模块不同不好参考. =================二进制安装mysql 系统:CentOS 6 x86_64 下载MySQL mkdir /soft  cd /soft && wget  解压MySQ

CentOS6+MySQL5.6二进制安装

一般我们安装mysql采用二进制安装的方式就足以满足我们的生产环境了,不过需要我们配置my.cnf文件 [[email protected] ~]#tar xvf mysql-5.6.16-linux-glibc2.5-x86_64.tar.gz mv mysql-5.6.16-linux-glibc2.5-x86_64 /usr/local/mysql [[email protected]]#groupadd mysql -g 512 [[email protected]]#useradd-u

mysql5.7二进制安装

介绍系统 rhel7.2-64安装方式 二进制MySQL 5.7高可用架构 主主备份方式 xtrabackup注意:其中1节点为生产环境,需要将现有数据xtrabackup,并在2号节点恢复,然后进行主主搭建,在2节点上进行change master 时候需要查看1节点的备份点,从这个备份点慢慢的追平.master1>cat Xtrabackup_binlog_info步骤上传安装包mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz创建用户Groupadd my

ubuntu mysql5.6二进制安装

200 ? "200px" : this.width)!important;} --> 介绍 以前一直使用centos今天需要对一台ubantu的系统安装mysql,虽然它也是类unix但是和redhat或centos命令上还是有点差别. 下载解压 wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz mv mysql-5.6.33-linux-gli

Linux下MySQL5.7.18二进制包安装(无默认配置文件my_default.cnf)

本文出处:http://www.cnblogs.com/wy123/p/6815049.html 最新在学习MySQL,纯新手,对Linux了解的也不多,因为是下载的最新版的MySQL(MySQL5.7.18)二进制包,CentOS7.2下测试安装,方便以后折腾.大概步骤如下,安装删除反复折腾了几遍,按照以下步骤,应该没啥问题了.也没有想象中的复杂,大部分步骤都是参考网上的,照做就是了,出错的话,多尝试,多查资料. 操作系统版本 创建mysql组和用户 下载最新版的MySQL 5.7.18二进制

Centos7 下Mysql5.7.18的安装和简单主从

Mysql5.7.18的安装 #下载解压tar包 wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz -C /usr/local/ cd /usr/local/ && mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql c

Mysql5.7.8安装文档(二进制安装)

5.7的二进制安装方法与5.6大概差不多,但有些地方不太一样,比如说,初始化命令的该变,5.7之后的小版本初始化命令也不相同.现在使用的是开发版的5.7.8. 第一步,下载解压二进制文件,加压,进入解压出来的文件 [[email protected] mysql33333]# ll total 160 drwxr-xr-x 2 7161 wheel 4096 Jul 20 20:54 bin -rw-r–r– 1 7161 wheel 17987 Jul 20 20:25 COPYING drw

轻松使用二进制安装Mysql5.6

二进制安装mysql5.6 系统环境:Centos6.5 x86_64 mysql二进制包:mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz #解压tar包到指定安装目录: cp mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz /data/ tar -zxf /data/mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz #创建mysql数据存储目录 mkdir /data/mysqldata

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