怎么用二进制包安装mysql
admin
2023-05-04 22:21:37
0次

目的

本文主要讲述如何使用二进制安装mysql,并启动mysql

1、mysql安装包的下载

https://dev.mysql.com/downloads/mysql/

2、安装mysql前的准备

  • 上传mysql安装包至/usr/local目录

  • 解压mysql安装包;

    [root@localhost local]# tar xvf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
  • 将解压后的文件夹连接至mysql文件夹

    [root@localhost local]# ln -s mysql-5.6.39-linux-glibc2.12-x86_64 mysql
  • 检查并安装依赖包(perl)

    [root@localhost scripts]# yum -y install perl perl-devel perl-Data-Dumper
> 如若未安装perl组件将会报以下错误

[root@localhost scripts]# ./mysql_install_db
FATAL ERROR: please install the following Perl modules before executing ./mysql_install_db:
Data::Dumper

- 检查并安装依赖包(libaio)

[root@localhost mysql]# yum list|grep libaio
libaio.i686                              0.3.109-13.el7                base    
libaio.x86_64                            0.3.109-13.el7                base    
libaio-devel.i686                        0.3.109-13.el7                base    
libaio-devel.x86_64                      0.3.109-13.el7                base    
[root@localhost mysql]# yum -y install libaio libaio-devel

> 若如为安装libaio组件将会报以下错误

[root@localhost mysql]# scripts/mysql_install_db --user=mysql
WARNING: The host 'Alinx' could not be looked up with ./bin/resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !

Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
[root@localhost mysql]#

###  3、创建mysql用户,用户组并将目录授权给mysql用户

[root@localhost scripts]# groupadd mysql
[root@localhost scripts]# useradd -r -g mysql mysql
[root@localhost ~]# chown mysql:mysql /usr/local/mysql -R
[root@localhost ~]# ll /usr/local/
total 321180
drwxr-xr-x.  2 root  root          6 Aug 12  2015 bin
drwxr-xr-x.  2 root  root          6 Aug 12  2015 etc
drwxr-xr-x.  2 root  root          6 Aug 12  2015 games
drwxr-xr-x.  2 root  root          6 Aug 12  2015 include
drwxr-xr-x.  2 root  root          6 Aug 12  2015 lib
drwxr-xr-x.  2 root  root          6 Aug 12  2015 lib64
drwxr-xr-x.  2 root  root          6 Aug 12  2015 libexec
lrwxrwxrwx   1 mysql mysql        35 Jan 16 22:46 mysql -> mysql-5.6.39-linux-glibc2.12-x86_64
drwxr-xr-x  13 mysql mysql      4096 Jan 16 22:38 mysql-5.6.39-linux-glibc2.12-x86_64
-rw-r--r--   1 root  root  328882304 Jan 21  2018 mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
drwxr-xr-x.  2 root  root          6 Aug 12  2015 sbin
drwxr-xr-x.  5 root  root         46 Jan 17  2017 share
drwxr-xr-x.  2 root  root          6 Aug 12  2015 src

> 此时可以看到mysql目录的归属为mysql:mysql
- 删除系统中的mysql配置文件

rm -f /etc/my.cnf
rm -fr /etc/my.cnf.d/

### 4、初始化并启动mysql
- 初始化

[root@localhost mysql]# scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data --skip-name-resolve

> 该步骤为创建了一个root用户(空密码),并初始化了mysql的一些权限账户表

- 拷贝配置文件以及启动脚本

[root@localhost mysql]# cp support-files/my-default.cnf /etc/my.cnf
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld

- 编辑/etc/my.cnf文件,并写入如下内容

basedir = /usr/local/mysql
datadir = /usr/local/mysql/data/

### 5、启动mysql

- 启动mysql

/usr/local/mysql/support-files/mysqld start

- 为mysql数据库设置密码(跟进提示进行密码设置,部署完时密码为空)

[root@localhost mysql]# ./bin/mysql_secure_installation

- 登录数据库

[root@localhost mysql]# mysql -uroot -pAlinx

> 当前启动时候报错(发现是/etc/my.cnf未配置目录导致)

[root@localhost support-files]# /usr/local/mysql/support-files/mysql.server start
Starting MySQL.Logging to '/usr/local/mysql/data/localhost.err'.
ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.pid).
[root@localhost support-files]#

上一篇:oracle11g手工建库

下一篇:Oracle 表操作

相关内容

热门资讯

空调连续工作多久需要停机休息 空调连续工作的时间取决于多个因素,包括空调的型号、功率、使用环境和维护情况等。一般来说,空调可以连续...
空调哪个符号是除湿的 空调除湿功能通常用一个水滴形状的符号表示。不同品牌和型号的空调遥控器可能会有所差异,但一般来说,除湿...
格力空调多长时间加一次氟利昂 1、一般情况下,空调对氟利昂的使用量是非常小的,所以在空调使用了四年左右的时候再考虑加也没问题。2、...
空调用多长时间需要加氟一次 一般情况下是五年。当出现以下这几种情况时,空调才需要加氟。1、空调的室内机和室外机各有两个接口,当接...
格调生活·C标思享荟:卡萨帝在... 9月12日的郑州龙湖金融岛,夜风轻拂,灯光璀璨。“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑...
品牌价值破千亿、高端份额持续领... 9月12日,“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑州站”在郑州龙湖金融岛举办。2026...
空调主板坏了修800还是换新的 空调主板坏了是修还是换新,需要考虑多个因素,以下是一些建议:1. 维修成本:如果维修费用较低,比如 ...
空调开多久需要休息多长时间 问题:空调开多久需要休息多长时间回答:1、在使用空调的过程中,一般空调开7~8个小时左右需要休息2~...
中央空调多长时间清洗一次 1、一般空调开机前清洗一次即可,空调开机中间时段再清洗一次,空调关机时清洗一次,这样比较合理。2、空...
中央空调氟利昂多久加一次 看空调制热和制冷程度,很多人的观点认为氟利昂必须一年放一次,其实这个观点是错误的,理解上面有点偏差,...