YUM安装数据库

1.获取rpm包

安装前,首先要关闭防火墙和selinux
mysql官方网站为www.mysql.com

wget https://dev.mysql.com/get/mysql80-community-releaseel7-3.noarch.rpm

wget 官网得到的地址 或者下载到本地然后上传到服务器

2.安装mysql的yum仓库

[root@mysql ~]# rpm -ivh  进行解压
[root@mysql ~]# yum -y install yum-utils          安装yum工具包

3.配置yum源

[root@mysql ~]# vim /etc/yum.repos.d/mysql-community.repo          
#Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

#Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

#Enable to use MySQL 5.7
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql-connectors-community]
name=MySQL Connectors Community
"/etc/yum.repos.d/mysql-community.repo" 72L, 2076C

根据mysql版本开启,我的是5.7所以开了5.7,1表示开启。0表示关闭

4.安装数据库

[root@mysql ~]# yum install -y mysql-community-server
[root@mysql ~]# systemctl start mysqld                                   启动服务
[root@mysql ~]# systemctl enable mysqld                                 设置开机启动

5.查找密码

密码保存在日志文件中
[root@mysql ~]# grep password /var/log/mysqld.log
2019-08-18T14:03:51.991454Z 1 [Note] A temporary password is generated for root@localhost: woHtkMgau9,w
冒号后的都是密码

6.修改密码(两种方式)

第一种
[root@mysql ~]# mysql -uroot -p'woHtkMgau9,w' 
mysql> alter user 'root'@'localhost' identified by 'ChenChao@123';

第二种
[root@mysql ~]# mysqladmin -uroot -p'ChenChao@123' password 'ChenChao!123'
mysqladmin: [Warning] Using a password on the command line interface can be
insecure.
Warning: Since password will be sent to server in plain text, use ssl connection
to ensure password safety.
——————————————————————————————————
启动 mysqld 服务
[root@mysql ~]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
查看服务状态

[root@mysql ~]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
停止 mysqld 服务

[root@mysql ~]# service mysqld stop
Redirecting to /bin/systemctl stop mysqld.service
查看服务的监听端口


[root@mysql ~]# ss -ntal
State       Recv-Q Send-Q Local Address:Port               Peer Address:Port
LISTEN      0      128     *:22                  *:*
LISTEN      0      128    :::22                 :::*
LISTEN      0      80     :::3306               :::*
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值