centos7安装mysql--亲测有效

本文详细介绍在Linux环境下安装MySQL数据库的过程,包括检查系统依赖、下载并安装repo源、安装MySQL服务、解决常见错误、重置管理员密码及创建hive用户等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、先检查系统是否装有mysql

rpm -qa | grep mysql

删除可用yum -y remove

2.下载mysql的repo源

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

安装mysql-community-release-el7-5.noarch.rpm包

sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm

 

安装这个包后,会获得两个mysql的yum repo源(在cd /etc/yum.repos.d/查看):

/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo。

3,。安装mysql

sudo yum install mysql-server

安装后再次查看mysq

rmp -qa | grep mysql

如果报错,内容含有

Error: Package: mysql-community-libs-5.6.35-2.el7.x86_64 (mysql56-community) Requires: libc.so.6(GLIBC_2.17)(64bit) Error: Package: mysql-community-server-5.6.35-2.el7.x86_64 (mysql56-community) Requires: libc.so.6(GLIBC_2.17)(64bit) Error: Package: mysql-community-server-5.6.35-2.el7.x86_64 (mysql56-community) Requires: systemd Error: Package: mysql-community-server-5.6.35-2.el7.x86_64 (mysql56-community) Requires: libstdc++.so.6(GLIBCXX_3.4.15)(64bit) Error: Package: mysql-community-client-5.6.35-2.el7.x86_64 (mysql56-community) Requires: libc.so.6(GLIBC_2.17)(64bit) You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest

解决:

#yum install glibc.i686 

# yum list libstdc++*

 

启动MySQL:service mysqld start

 

4、重置密码

重置密码前,首先要登录

mysql -u root

mysql > use mysql;

mysql > update user set password=password('123456') where user='root'; mysql > exit;

重启mysql服务后才生效 # service mysqld restart

必要时加入以下命令行,为root添加远程连接的能力。链接密码为 “root”(不包括双引号)

mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";  

到此,安装完毕

5.创建hive用户

创建一个新的数据库:create database hive;

创建一个新的用户:

 create user 'hiveowner'@'%' identified by 'Welcome_1';

  

给该用户授权

grant all on hive.* TO 'hiveowner'@'%';

grant all on hive.* TO 'hiveowner'@'localhost' identified by 'Welcome_1';

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值