Linux下安装mysql-5.7.30详细步骤
前⾔
下⾯记录了我在Linux环境下安装Mysql的完整过程,实操记录,只为让更多⼈少踩坑,本次安装版本为:mysql-5.7.30,64位操作系统官⽹下载地址:mysql-5.7.30-el7-x86_
百度⽹盘地址:百度⽹盘地址提取码:lyqh
1、安装前准备
检测系统是否⾃带mysql
[root@localhost /]# rpm -qa | grep mysql
如果是,则使⽤下⾯命令进⾏删除:
[root@localhost /]# rpm -e --nodeps ‘上⼀步查的名称’
删除成功后,查询所有Mysql对应的⽂件夹
[root@localhost ~]# whereis mysql
mysql: /usr/bin/mysql /usr/local/mysql
[root@localhost ~]# find / -name mysql
/run/lock/subsys/mysql
/etc/rc.d/init.d/mysql
/usr/bin/mysql
/usr/local/mysql
/usr/local/mysql/bin/mysql
/usr/local/mysql/include/mysql
/usr/local/mysql/data/mysql
删除上⾯查的所有⽂件夹
2、安装
使⽤rz命令上传下载好的jar包
[root@localhost ~]# cd /usr/local/
[root@localhost local]# rz
解压
[root@localhost local]# tar -zxvf mysql-5.7.30-el7-x86_
修改解压⽬录名称
[root@localhost local]# mv mysql-5.7.30-el7-x86_64/ mysql
在/usr/local/mysql⽬录下创建data⽬录
[root@localhost local]# mkdir mysql/data
检查mysql⽤户组和⽤户是否存在,如果没有,则创建
[root@localhost local]# cat /etc/group | grep mysql
[root@localhost local]# cat /etc/passwd | grep mysql
[root@localhost local]# groupadd mysql
[root@localhost local]# useradd -r -g mysql mysql
更改mysql⽬录下所属的⽤户组和⽤户,以及权限
[root@localhost local]# chown -R mysql:mysql /usr/local/mysql/
[root@localhost local]# chmod -R 755 /usr/local/mysql
编译安装并初始化mysql
[root@localhost local]# cd mysql/bin/
[root@localhost bin]# ./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data/ --basedir=/usr/local/mysql/
8. 查看并安装libaio包
[root@localhost bin]# rmp -qa|grep libaio
-bash: rmp: command not found
[root@localhost bin]# yum -y install libaio-devel.x86_64
9.再次执⾏步骤7,并记住⽇志最后的初始化密码(记住)
10.编辑配置⽂件myf
[root@localhost bin]# vi /etc/myf
添加配置如下
[mysqld]
datadir=/usr/local/mysql/data
port=3306
# 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 /wiki/Systemd
[mysqld_safe]
log-error=/usr/local/mysql/data/mysql.log
pid-file=/usr/local/mysql/data/mysql.pid
mysql下载jar包11.启动mysql服务器
[root@localhost bin]# /usr/local/mysql/support-files/mysql.server start
13. 添加软连接,并重启mysql服务
[root@localhost bin]# ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql [root@localhost bin]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
[root@localhost bin]# service mysql restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
14.登录mysql,修改密码为123456(登录的密码是步骤9中初始化密码) [root@localhost bin]# mysql -u root -p
Enter password:
mysql>set password for root@localhost = password('123456');
15.开放远程连接
mysql>use mysql;
msyql>update user set user.Host='%' where user.User='root';
mysql>flush privileges;
3、测试
1.关闭Linux防⽕墙
[root@localhost bin]# systemctl stop firewalld.service
2.Navicat连接测试
结束语
如果本篇对您有帮助,请点个赞再加个关注,您的点赞是博主前进的动⼒!
本篇详细的介绍了mysql-5.7.30的详细安装步骤,为mysql的主从复制教程提供了基础。
感兴趣的同学可以看看博主下⼀篇linux下搭建mysql主从复制。
————————————————
版权声明:本⽂为CSDN博主「夏夜凉⽉的博客」的原创⽂章,遵循CC 4.0 BY-SA版权协议,转载请附上原⽂出处链接及本声明。原⽂链接:blog.csdn/cool_summer_moon/article/details/106090136

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。