当前位置: 移动技术网 > IT编程>数据库>Mysql > Centos7 安装 Mysql8教程

Centos7 安装 Mysql8教程

2020年08月14日  | 移动技术网IT编程  | 我要评论

mysql8新特性:

mysql从5.x版本直接跳跃到8.x,我个人是这么看的:

mysql 5.5 -> mysql 5
mysql 5.6 -> mysql 6
mysql 5.7 -> mysql 7
mysql 8.0 -> mysql 8

当然也有可能是mysql6、7内部难产了-_-,自从被oracle收购后,活力依旧在,mysql8有以下新特性:

  • mysql 文档存储
  • 默认 utf8mb4 编码
  • json 增强
  • ctes(译者注:common table expresssions 公共表格表达式)
  • 窗口函数
  • 降序索引
  • 更好的优化器消费模型
  • mysql 服务器组件
  • gis(译者注:geographic information system 地理信息系统) 提升
  • innodb 引擎的 no wait 和 skip \ locked 选项

centos7 mysql8安装步骤:

1、设置mysql源

首先,您需要在mysql提供的系统中启用mysql yum存储库。 根据您的操作系统版本执行以下命令之一,这里我们选择centos 7 / rhel 7的源

###在centos 7 / rhel 7系统上### 
rpm -uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm

###在centos 7 / rhel 6系统上### 
rpm -uvh https://repo.mysql.com/mysql80-community-release-el6-3.noarch.rpm

###在fedora 30系统上### 
rpm -uvh https://repo.mysql.com/mysql80-community-release-fc30-1.noarch.rpm

###在fedora 29系统上### 
rpm -uvh https://repo.mysql.com/mysql80-community-release-fc29-2.noarch.rpm

###在fedora 28系统上### 
rpm -uvh https://repo.mysql.com/mysql80-community-release-fc28-2.noarch.rpm

2、安装mysql community server

mysql yum存储库包含用于多个mysql版本的多个存储库配置。 因此,首先禁用mysql repo文件中的所有存储库

sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo

启用centos mysql8版本

## centos & redhat 版本
yum --enablerepo=mysql80-community install mysql-community-server
## fedora systems 版本
dnf --enablerepo=mysql80-community install mysql-community-server

3、启动mysql服务

service mysqld start

使用systemd

systemctl start mysqld.service

4、查找mysql root密码

安装mysql 8.0后,将为mysql根用户创建一个临时密码。 您可以在日志文件中找到生成的临时密码。密码文件位置:/var/log/mysqld.log

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

5、重置root密码

首次安装mysql后,执行mysql_secure_installation命令以保护mysql服务器,包含重置密码步骤

mysql_secure_installation
enter password for user root:

the existing password for the user account root has expired. please set a new password.

new password:
re-enter new password:

remove anonymous users? (press y|y for yes, any other key for no) : y

disallow root login remotely? (press y|y for yes, any other key for no) : y

remove test database and access to it? (press y|y for yes, any other key for no) : y

reload privilege tables now? (press y|y for yes, any other key for no) : y

6、mysql 服务加入开机启动项,并启动mysql进程

### using systemd
systemctl enable mysqld.service
systemctl restart mysqld.service

7、开放3306端口

如果服务器开启了防火墙,记得开启3306端口

systemctl enable iptables
systemctl start iptables
vim /etc/sysconfig/iptables
##规则中加入
-a input -p tcp -m state --state new -m tcp --dport 3306 -j accept
##重启防火墙
systemctl enable iptables.service
systemctl start iptables.service

如果使用的腾讯云的服务器,一定记得开启安全组里的端口

附mysql常用命令:

登录mysql

mysql -u username -p

启动mysql

systemctl start mysqld.service

结束mysql

systemctl stop mysqld.service

重启mysql

systemctl restart mysqld.service

开机自启

systemctl enable mysqld.service

以上就是centos7 安装 mysql8教程的详细内容,更多关于centos7 安装 mysql8的资料请关注移动技术网其它相关文章!

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网