安装MYSQL5.7.32 亲测

==下载环节

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz

========检查环境环节

  1. 检测自带mysql

#rpm -qa | grep mysql

2.删除 “1” 找到的 所有

#rpm -e --nodeps ‘名称’

3.查询所有mysql文件夹

#whereis mysql

#find / -name mysql

删除所有结果 (rm -rf ‘文件路径’)

========安装环节

1. 切换路径

#cd /usr/local

2.拷贝mysql安装包到此目录下 (界面操作)

3.解压安装包

#tar -zxvf ‘mysql tart.gz包名’

4.重命名

#mv ‘解压后的文件夹名称’ mysql

## 5. 在 /usr/local/mysql目录下创建data目录

#mkdir mysql/data

6.检查mysq用户组和用户是否存在,没有则创建

#cat /etc/group | grep mysql

#cat /etc/passwd | grep mysql

#groupadd mysql

#useradd -r -g mysql mysql

7.更改mysql目录下所属的用户组和用户, 以及权限

#chown -R mysql:mysql /usr/local/mysql

#chmod -R 755 /usr/local/mysql

8.编译安装并初始化mysql

#cd mysql/bin

#./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql

拷贝出生成的默认密码, 后面要用。(大概在:root@localhost 后边)

9. 查看并安装libaio 包 (第8步执行错误未生成密码,则做第9步的检查。 实践环境 麒麟操作系统, 没有做这一步, 也没有做第10步)

#rpm -qa | grep libaio

#yum -y install libaio -devel.x86_64

10.再次执行第8步 。

11.编辑 my.cnf

#vim /etc/my.cnf

bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

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

#character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

12.启动mysql服务器

#/usr/local/mysql/support-files/mysql.server start

如果报错Starting MySQL.2020-11-21T01:27:45.025860Z mysqld_safe error: log-error set to ‘/data/mysql/mysql.err’, however file don’t exists. Create writable for user ‘mysql’.
ERROR! The server quit without updating PID file (/usr/local/mysql/data/VM-0-2-centos.pid).看你是不是设置对了my.cnf.d

13.添加软链接,重启mysql服务

#ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

#ln -s /user/local/mysql/bin/mysql /user/bin/mysql

#service mysql restart (提示不同,依据提示操作)

14.登录 mysql 修改密码

mysql -uroot -p

输入上面生成的默认密码

set password for root@localhost =password(‘新密码’);

15.开放远程连接

use mysql

update user set user.Host=’%’ where user.User=‘root’;

flush privileges

16.关闭防火墙

#systemctl stop firewalld.service (根据提示操作)

==配置开机重启

1.#cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

2#chmod +x /etc/init.d/mysqld

3.添加服务

#chkconfig --add mysqld

查看查看列表

#chkconfig --list

3,4,5状态为开或者on 则成功。 若为 关或off : 则

#chkconfig --level 345 mysqld on

4.#reboot 重启

5.查看mysql监听状态

#netstat -na | grep 3306

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值