数据库二进制安装

二进制安装   

mysql官网:www.mysql.com

准备虚拟机:db04(10.0.0.54)  安装版本:msyql-5.6.44  

安装目录:/opt/mysql-5.6.44

1.下载安装包

[root@db04 ~]# wget https://downloads.mysql.com/archives/get/file/mysql-5.6.44-linux-glibc2.12-x86_64.tar.gz

 

2.解压安装包

[root@db04 ~]# tar xf mysql-5.6.44-linux-glibc2.12-x86_64.tar.gz

 

3.创建mysql用户

[root@db04 ~]# useradd mysql -s /sbin/nologin -M

4.创建安装mysql目录

[root@db04 ~]# mkdir -p /opt

 

5.移动安装包到安装目录

[root@db04 ~]# mv mysql-5.6.44-linux-glibc2.12-x86_64 /opt/mysql-5.6.44 [root@db04 ~]# ll /opt/mysql-5.6.44/ total 40 drwxr-xr-x 2 root root 4096 Oct 30 23:30 bin -rw-r--r-- 1 7161 31415 17987 Mar 15 2019 COPYING drwxr-xr-x 3 root root 18 Oct 30 23:30 data drwxr-xr-x 2 root root 55 Oct 30 23:30 docs drwxr-xr-x 3 root root 4096 Oct 30 23:30 include drwxr-xr-x 3 root root 316 Oct 30 23:30 lib drwxr-xr-x 4 root root 30 Oct 30 23:30 man drwxr-xr-x 10 root root 291 Oct 30 23:30 mysql-test -rw-r--r-- 1 7161 31415 2496 Mar 15 2019 README drwxr-xr-x 2 root root 30 Oct 30 23:30 scripts drwxr-xr-x 28 root root 4096 Oct 30 23:30 share drwxr-xr-x 4 root root 4096 Oct 30 23:30 sql-bench drwxr-xr-x 2 root root 136 Oct 30 23:30 support-files

 

6.创建软链接

[root@db04 ~]# ln -s /opt/mysql-5.6.44/ /opt/mysql

 

7.拷贝启动脚本

[root@db04 ~]# cd /opt/mysql-5.6.44/support-files/ [root@db04 support-files]# cp mysql.server /etc/init.d/mysqld

8.拷贝配置文件

[root@db04 support-files]# cp my-default.cnf /etc/my.cnf cp: overwrite ‘/etc/my.cnf’? y

 

9.初始化系统

[root@db04 support-files]# cd /opt/mysql-5.6.44/scripts/

[root@db04 scripts]# yum install -y libaio* autoconf

[root@db04 scripts]# ./mysql_install_db --basedir=/opt/mysql --datadir=/opt/mysql/data --user=mysql

 

10.授权mysql目录

[root@db04 scripts]# chown -R mysql.mysql /opt/mysql*

[root@db04 scripts]# ll /opt/

total 0

lrwxrwxrwx 1 mysql mysql 18 Oct 30 23:32 mysql -> /opt/mysql-5.6.44/

drwxr-xr-x 13 mysql mysql 205 Oct 30 23:40 mysql-5.6.44

 

11.修改启动脚本程序

[root@db04 scripts]# sed -i 's#/usr/local#/opt#g' /etc/init.d/mysqld /opt/mysql/bin/mysqld_safe

 

12.启动mysql

[root@db04 scripts]# /etc/init.d/mysqld start

Starting MySQL.Logging to '/opt/mysql/data/db04.err'. . SUCCESS!

 

13.添加环境变量

[root@db04 scripts]# vim /etc/profile.d/mysql.sh

export PATH="/opt/mysql/bin:$PATH"

14.启动环境变量

[root@db04 scripts]# source /etc/profile

15.检查端口号

[root@db04 scripts]# netstat -lntup

tcp6 0 0 :::3306 :::* LISTEN 8902/mysqld

 

登录:mysql

[root@db04 scripts]# mysql

Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.44 MySQL Community Server (GPL) 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> \q Bye

猜你喜欢

转载自www.cnblogs.com/ronglianbing/p/11769333.html
今日推荐