Linux中安装MySQL

在Linux中安装MySQL

1.编辑版本下载地址
vim /etc/yum.repos.d/mysql-community.repo

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

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

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/6/$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/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
2.下载MySQL:
1)下载rpm包
wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
2.安装rpm
rpm -ivh mysql57-community-release-el6-7.noarch.rpm
3.yum 安装
yum install -y mysql-community-client mysql-community-server

yum install -y net-tools 安装依赖文件net-tools

将我发的mysql-community-server的rpm包发送到虚拟机。 mysql-community-server
rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm 安装

4.启动服务
systemctl start mysqld
systemctl enable mysqld

5.查看临时密码 最后写是临时密码
cat /var/log/mysqld.log | grep “temporary password”
如果没有显示出密码,可以删除/var/lib/mysql,然后重新启动服务

注意:然后通过 mysql -u root -p 回车, 进入后将临时密码粘贴进去,回车就进去了。

6.修改密码
alter user ‘root’@‘localhost’ identified by ‘123456你自己得mysql密码’;
报错就执行下面两句 再次重新修改密码:
set global validate_password_policy=LOW;
set global validate_password_length=4;

7.打开远程连接
update mysql.user set host=’%’ where user=‘root’;

8.刷新授权
flush privileges;

9.重启服务
service mysqld restart

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值