美文网首页工作生活
Linux mysql8.0安装和卸载

Linux mysql8.0安装和卸载

作者: marioplus12 | 来源:发表于2019-07-02 01:37 被阅读0次

卸载

  • 卸载之前请确保数据都备份好了阿!

查看是否安装mysql

rpm -qa | grep -i mysql
image.png

挨个卸载: rpm -e –nodeps 包名

rpm -e –nodeps mysql-community-libs-8.0.16-2.el7.x86_64

查找之前老版本mysql的目录、并且删除老版本mysql的文件和库

find / -name mysql

挨个删除

rm -rf /var/lib/mysql
rm -rf /usr/lib64/mysql
...
  • 注意:卸载后/etc/my.cnf不会删除,需要进行手工删除
rm -rf /etc/my.cnf

检查一遍

rpm -qa | grep -i mysql
find / -name mysql

安装(8.0)

添加MySQL Yum存储库

进入Yum Repository下载页面选择我们需要的版本,点击Download进入下载页面。

一般选这个

image.png

进入下载页面可以拿到下载地址

image.png

下载到机器上

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

安装存储库

yum localinstall mysql80-community-release-el7-3.noarch.rpm

安装mysql

通过以下命令安装mysql

yum install mysql-community-server

启动MySQL服务器

使用以下命令启动MySQL服务器:

service mysqld start

使用以下命令检查MySQL服务器的状态:

service mysqld status

修改mysql配置文件

vim /etc/my.cnf

给出一个简单的作参考

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html#
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

# 允许最大连接数
max_connections=20
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 设置协议认证方式(重点啊)
default_authentication_plugin=mysql_native_password
# 默认时区
default-time_zone = '+8:00'
# 去掉group限制
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
# 密码验证强度
# 默认为:MEDIUM
# 要求至少包含1个数字字符,1个小写字符,1个大写字符和1个特殊(非字母数字)字符
# 非测试环境请勿添加此项
validate_password.policy=LOW
# 密码验证长度,默认:8
# 非测试环境请勿添加此项
validate_password.length=6

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4

重启mysql

systemctl restart mysqld

修改密码

查看默认密码

grep 'temporary password' /var/log/mysqld.log

如果有多行,以最下面一条为准。

登录mysql

mysql -uroot -p

然后输入上面看到的临时密码,小技巧可以使用在中文输入法下输入,密码会在输入法的框框中看得到

需要远程登录
# 切换数据库
use mysql;

# 查看用户信息
select host, user from user;

# 修改root用户访问限制
update user set host='%' where user='root';

#  刷新权限
FLUSH PRIVILEGES;

# 查看用户信息
select host, user from user;
image.png
  • 注意: 默认情况下root用户对应的host是localhost,图中是因为我已经修改过了。

修改密码

ALTER USER 'root'@'%' IDENTIFIED BY '123456'
FLUSH PRIVILEGES;
不需要远程登录

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'
FLUSH PRIVILEGES;

引用

相关文章

  • Linux mysql8.0安装和卸载

    卸载 卸载之前请确保数据都备份好了阿! 查看是否安装mysql 挨个卸载: rpm -e –nodeps 包名 查...

  • window 安装 MySQL8.0.24 修改xampp的ma

    一、window 安装 MySQL8.0.24Windows安装和完全卸载MySQL8.0(超详细教程)https...

  • Nginx 代理 MySQL

    1). Centos7.5 安装 Mysql8.0 2). Linux 安装Nginx 3). 修改配置文件 在 ...

  • jdk的安装及配置

    JDK的安装和卸载:安装: 检查Linux自带OpenJDK:[root@localhost xxx] rpm -...

  • mysql8.0安装及问题

    CentOS 7 rpm 安装MySQL 详解 linux安装mysql8.0及开启远程访问 解决MySQL8.0...

  • 【教程】Linux下MySQL 8.0安装配置

    1、编译安装MySQL8.0 版本信息 cat /etc/redhat-release CentOS Linux ...

  • mysql安装

    CentOS7安装mysql8.0步骤 1.1 安装前清理工作(卸载mysql);1.1.1 清理原有的mysql...

  • vim

    linux 安装:yum -y install 安装名linux 卸载:yum -y remove 安装名yum...

  • CentOS6.8安装JDK

    检查Linux系统是否已经安装jdk 卸载系统自带的java 查看卸载结果 卸载成功下载jdk安装包 安装jdk ...

  • win10内建的Linux

    启用Linux子系统 从cmd中下载linux和linux终端安装程序一样 卸载linux子系统 删除 %USER...

网友评论

    本文标题:Linux mysql8.0安装和卸载

    本文链接:https://www.haomeiwen.com/subject/uinocctx.html