二进制方式安装mysql_二进制方式安装mysql5.7.24

1. 实验环境

[root@test-mysql ~]# cat /etc/redhat-release

CentOS Linux release 7.3.1611 (Core)

2. 浏览器下载mysql安装包或者使用wget下载,并解压

[root@test-mysql ~]# cd /usr/local/src

[root@test-mysql src]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-el7-x86_64.tar.gz

[root@test-mysql src]# tar xf mysql-5.7.24-el7-x86_64.tar.gz -C /usr/local/

3. 创建软链接方便版本升级或者回退

[root@test-mysql src]# cd ..

[root@test-mysql local]# ln -s /usr/local/mysql-5.7.24-el7-x86_64/ /usr/local/mysql

[root@test-mysql local]# cd mysql

4. 创建数据目录、用户并进行授权

[root@test-mysql mysql]# mkdir data

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

[root@test-mysql mysql]# chown -R mysql. ./

5. 初始化mysql

[root@test-mysql mysql]# ./bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data/ --basedir=/usr/local/mysql

./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

-----------------------------------------------------------------------------------------------------------------------------

# 如果是CentOS 6.x 的环境可能会报error while loading shared libraries: libnuma.so.1: cannot open shared object file

[root@test-mysql mysql]# yum -y install numactl

-----------------------------------------------------------------------------------------------------------------------------

#报错缘由是没有安装libaio,安装后再次执行初始化命令,初始化完成后最后一行会显示密码。

[root@test-mysql mysql]# yum -y install libaio

[root@test-mysql mysql]# ./bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql

2019-04-15T02:48:04.263308Z 1 [Note] A temporary password is generated for root@localhost: KlLoAKJeZ0

6. 编辑用户配置文件,尝试启动mysql

[root@test-mysql mysql]# cp /etc/my.cnf{,.bak}

[root@test-mysql mysql]# vim /etc/my.cnf

[mysql]

prompt=MySQL [\d]>

[mysqld]

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data

log_error=/var/log/mysql.log

[root@test-mysql mysql]# cp support-files/mysql.server /etc/init.d/mysqld

[root@test-mysql mysql]# /etc/init.d/mysqld start

Starting MySQL. SUCCESS!

[root@test-mysql mysql]# cd /etc/init.d/

[root@test-mysql init.d]# chkconfig --add mysqld

[root@test-mysql init.d]# chkconfig mysqld on

[root@test-mysql init.d]# lsof -i:3306

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

mysqld 26400 mysql 28u IPv6 383088 0t0 TCP *:mysql (LISTEN)

7. 将mysql的命令目录添加至PATH变量,方便使用

[root@test-mysql init.d]# echo 'export PATH=/usr/local/mysql/bin:$PATH' >>/etc/profile

[root@test-mysql init.d]# source /etc/profile

8. 修改mysql密码,并登入。

#修改密码需要先输入旧密码,旧密码在初始化mysql的时候有自动生成。

[root@test-mysql init.d]# mysqladmin -uroot -p password

[root@test-mysql init.d]# mysql -uroot –p

mysql> \q

Bye

写作不易,转载请注明出处,谢谢~~

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值