0


大数据之在Liunx中安装MySQL

文章目录

Linux MySQL安装教程

准备工作

关闭防火墙

# 停止firewall
systemctl stop firewalld.service

# 禁止firewall开机启动
systemctl disable firewalld.service

# 查看防火墙状态
systemctl status firewalld.service

修改主机名

vim /etc/hostname
# 查看主机名
hostname

配置静态IP

# 停止NetworkManager服务
systemctl stop NetworkManager
# 取消NetworkManager服务开机自启
systemctl disable NetworkManager

# 修改配置文件,配置静态IP
cd /etc/sysconfig/network-scripts
vim ifcfg-ens33

# 以下配置仅供参考!!!需要根据自己的实际情况配置
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
NAME=ens33
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.190.100
NETMASK=255.255.255.0
GATEWAY=192.168.190.2
DNS1=192.168.190.2

# 重启网络服务
systemctl restart network

CentOS换源

1. 备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2. 下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/

CentOS 6

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo

CentOS 7

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

或者

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

CentOS 8

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo

或者

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
3. 运行 yum makecache 生成缓存
4. 其他

非阿里云ECS用户会出现 Couldn’t resolve host ‘mirrors.cloud.aliyuncs.com’ 信息,不影响使用。用户也可自行修改相关配置: eg:

sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

安装mysql5.7

按照下面顺序依次复制粘贴即可

下载yum Repository

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

安装yum Repository

yum -y install mysql57-community-release-el7-10.noarch.rpm

安装mysql5.7 m’y

yum -y install mysql-community-server

开机自启动

systemctl enable mysqld.service

启动mysql

systemctl start mysqld.service

查看状态

systemctl status mysqld.service

获取临时密码

grep "password" /var/log/mysqld.log

把获取的临时密码拷贝一下

登录mysql

mysql -uroot -p [粘贴上刚刚获取的临时密码]

关闭密码复杂验证

set global validate_password_policy=0;
set global validate_password_length=1;

设置密码

alter user user() identified by "123456";

切换数据库

use mysql;

修改权限

开放root用户远程登录

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

刷新权限

flush privileges;

查看权限

select host,user,authentication_string from user; 

修改MySQL编码

  • 编辑配置文件:vim /etc/my.cnf``````[client]default-character-set = utf8mb4[mysqld]character-set-server = utf8mb4collation-server = utf8mb4_general_ci
  • 重启MySQLsystemctl restart mysqld- 登录并查看MySQL编码# 123456需替换为自己的密码mysql -uroot -p123456# 需在MySQL的shell中执行show variables like "%char%";

其它操作

卸载yum Repository

因为安装了Yum Repository,以后每次yum操作都会自动更新,需要把这个卸载掉

yum -y remove mysql57-community-release-el7-10.noarch

卸载mysql

删除依赖包

rpm -qa |grep -i mysql
yum remove mysql-community mysql-community-server mysql-community-libs mysql-community-common

清理文件

find / -name mysql
rm -rf [文件名]

到底啦!给靓仔一个关注吧!💝


本文转载自: https://blog.csdn.net/hujieliang123/article/details/122407525
版权归原作者 liangzai2048 所有, 如有侵权,请联系我们删除。

“大数据之在Liunx中安装MySQL”的评论:

还没有评论