UBUNTU 16.04 LTS SERVER 手动升级 MariaDB 到最新版 10.2

1. 起因

最近因为不同软件的数据问题本来只是一些小事弄着弄着就越弄越麻烦了,期间有这么个需求,没看到有中文资源,特记录一文。

2. 升级

2.1 手动添加源并安装

切记!在做任何改动前务必先用 mysqldump 将所有数据先备份出来!!!血的教训啊。。通宵了我两晚才将数据恢复回去

首先,确认你机子上有装 software-properties-common:

sudo apt-get install software-properties-common

接着添加 MariaDB 的仓库公钥到包管理中:

sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8

然后添加 MariaDB 10.1 的源:

sudo sh -c "echo 'deb https://mirrors.evowise.com/mariadb/repo/10.1/ubuntu '$(lsb_release -cs)' main' > /etc/apt/sources.list.d/MariaDB101.list"

这里最好是一步一步升级,所以先装 10.1 接着再升 10.2. 升级:

# 更新
sudo apt-get update # 升级
sudo apt-get install mariadb-server mariadb-client

然后添加 MariaDB 10.2 的源:

sudo sh -c "echo 'deb https://mirrors.evowise.com/mariadb/repo/10.2/ubuntu '$(lsb_release -cs)' main' > /etc/apt/sources.list.d/MariaDB102.list"

升级:

# 更新
sudo apt-get update
# 升级
sudo apt-get install mariadb-server mariadb-client

到这里就手动升级完了,接着就是用 mysqldump 把数据还原回去了。

2.2 "unix_socket" 的错误解决办法

如果你从低版本升级到高版本或者从 MySQL 升到 MariaDB 都可能会遇到,比如刚装好的数据库不能登陆 root 账户了:

mysql "ERROR 1524 (HY000): Plugin 'unix_socket' is not loaded"

这是因为这个叫 “unix_socket” 的东西是 MySQL 的一个认证的进程,但是在新的版本中它移除掉了!所以你的登陆就不能正常地认证了。。

解决办法如下:

先切成超管:

sudo su

接着彻底停掉 MySQL 并绕过验证地连上去:

/etc/init.d/mysql stop
mysqld_safe --skip-grant-tables &
mysql -uroot

完了下面的几句在 SQL Shell 中运行:

# 用 mysql 库
use mysql; # 重置密码
update user set password=PASSWORD("mynewpassword") where User='root'; # 重设验证方式,去掉 unix_socket 恢复成正常的认证方式
update user set plugin="mysql_native_password"; # 退出 SQL Shell
quit;

重启 MySQL:

/etc/init.d/mysql stop
kill -9 $(pgrep mysql)
/etc/init.d/mysql start

接着应该就能正常登陆了:

mysql -uroot -p

2.3 MariaDB 安全

下面这个命令可以自动设置一些数据库安全的东西,选做:

mysql_secure_installation

这个命令运行后会设置新的 root 密码,去除匿名用户,取消远程 root 的登陆并删除 test 库。

下面是运行的输出:

root@aliyun:/www# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here. Enter current password for root (enter for none):
OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation. You already have a root password set, so you can safely answer 'n'. Change the root password? [Y/n] n
... skipping. By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment. Remove anonymous users? [Y/n] y
... Success! Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y
... Success! By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment. Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success! Reloading the privilege tables will ensure that all changes made so far
will take effect immediately. Reload privilege tables now? [Y/n] y
... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB
installation should now be secure. Thanks for using MariaDB!

运行下面的命令可以查看数据库版本:

mysql -V
mysql Ver 15.1 Distrib 10.2.14-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

参考:

INSTALL / UPGRADE TO MARIADB 10.1 / 10.2 / 10.3 LATEST ON UBUNTU 16.04 LTS SERVER

Ubuntu 15.10 mysql error 1524 - unix_socket

完。

UBUNTU 16.04 LTS SERVER 手动升级 MariaDB 到最新版 10.2的更多相关文章

  1. 将 Ubuntu 16.04 LTS 升级到 Ubuntu 18.04 LTS

    将 Ubuntu 16.04 LTS 升级到 Ubuntu 18.04 LTS   Ubuntu 18.04 LTS(Bionic Beaver)即将发布, 如果您正在使用Ubuntu 16.04LT ...

  2. 从Ubuntu 14.04 LTS版升级到Ubuntu 16.04 LTS

      Ubuntu 16.04 (Xerial Xerus) Long Term Support版于最近发布了.要想了解它的新功能和新特性,就必须升级或安装这个新系统. 本文讲述怎样一步步从Ubuntu ...

  3. Ubuntu 16.04 LTS 安装 Nginx/PHP 5.6/MySQL 5.7 (LNMP) 与Laravel

    Ubuntu 16.04 LTS 安装 Nginx/PHP 5.6/MySQL 5.7 (LNMP) 与Laravel 1.MySQL安装[安装 MariaDB]MariaDB是MySQL的一个分支首 ...

  4. Ubuntu 16.04 LTS安装好需要设置的15件事(喜欢新版本)

    看到这篇文章说明你已经从老版本升级到 Ubuntu 16.04 或进行了全新安装,在安装好 Ubuntu 16.04 LTS 之后建议大家先做如下 15 件事.无论你是刚加入 Ubuntu 行列的新用 ...

  5. Ubuntu 16.04 LTS 降级安装GCC 4.8

    转载自https://www.linuxidc.com/Linux/2017-03/142299.htm Ubuntu 16.04 LTS 降级安装GCC 4.8 [日期:2017-03-28] 来源 ...

  6. Ubuntu 16.04 LTS安装好之后需要做的15件事

    看到这篇文章说明你已经从老版本升级到 Ubuntu 16.04 或进行了全新安装,在安装好 Ubuntu 16.04 LTS 之后建议大家先做如下 15 件事.无论你是刚加入 Ubuntu 行列的新用 ...

  7. Ubuntu 16.04 LTS (Xenial Xerus)

    Canonical刚刚正式发布了Ubuntu 16.04 LTS (Xenial Xerus),这是一个长期支持版本,官方会提供长达5年的技术支持(包括常规更新/Bug修复/安全升级),一直到2021 ...

  8. Ubuntu 16.04 LTS U盘安装要点

    一.UltraISO UltraISO是一款功能强大而又方便实用的光盘映像文件制作/编辑/转换工具,它可以直接编辑ISO文件和从ISO中提取文件和目录,也可以从CD-ROM制作光盘映像或者将硬盘上的文 ...

  9. Ubuntu 16.04 LTS 正式发布:系统将持续更新5年

    Canonical 刚刚正式发布了Ubuntu 16.04 LTS (Xenial Xerus),这是一个长期支持版本,官方会提供长达5年的技术支持(包括常规更新/Bug修复/安全升级),一直到202 ...

随机推荐

  1. NVIDIA Nsight Systems CUDA 跟踪

    NVIDIA Nsight Systems CUDA 跟踪 CUDA跟踪 NVIDIA Nsight Systems能够捕获有关在概要过程中执行CUDA的信息. 可以在报告的时间轴上收集和呈现以下信息 ...

  2. 运用iGuard防御ADS权限维持

    权限维持是一门庞大的学问,当攻击者在入侵服务器获得主机权限后,往往会想尽办法隐藏其入侵途径以维持权限.权限维持的一般手段包括构造文件包含漏洞.构造远程任意代码执行漏洞.构造SQL注入点.利用系统自启动 ...

  3. 一枚通过参数污染绕过百度RASP的XSS

    日常工作过程中,偶然发现一个网站登录页面,在页面返回包中存在一个隐藏参数"mess",且该页面部署了百度RASP进行防护,本文介绍如何发现隐藏参数以及如何通过参数污染方式造成XSS ...

  4. Springboot-Redis分布式锁 -----StringRedisTemplate

    这里引用别人, 用来自己回忆 https://blog.csdn.net/jack_shuai/article/details/91986690 https://www.cnblogs.com/mox ...

  5. jsp页面抽取

    步骤: 1.先将jsp中要抽取的公共部分剪切出来,黏贴到新的jsp文件中,取名叫xxx.jsp 2.在需要引入此公共部分的jsp页面中使用<%@include file="xxx.js ...

  6. Hive窗口函数保姆级教程

    在SQL中有一类函数叫做聚合函数,例如sum().avg().max()等等,这类函数可以将多行数据按照规则聚集为一行,一般来讲聚集后的行数是要少于聚集前的行数的.但是有时我们想要既显示聚集前的数据, ...

  7. 导出 Excel 模板自动生成规则,避免用户来回修改

    一句话总结 Excel 导出.导入时,根据注解自动添加单元格验证规则,避免用户因填写错误的枚举字段而反复修改 Excel 需求背景 对于 Java Web 项目,总是不可避免的出现 Excel 导入. ...

  8. 【TCP/IP】TCP服务器并发处理&源码

    前言 本笔记记录的是 单个服务端并发式处理多个客户端. 下次有空在发个 单线程多个服务端并发式处理多种客户端.其实就是本笔记的一个改良版,用到select() / poll() / epoll(). ...

  9. 在vue中下拉框切换事件中改新建表单中的一个值,页面不显示

    事件中改新建表单中的一个值,页面不显示,当另一个对象值发生改变时,这个页面上的值才会显示 由于新建表单是弹窗,在弹出时会重新给每个字段重新赋值,在赋值时没给这个字段赋值(常见新加功能时,加了一个字段, ...

  10. Murmur3 Hash 128位java和C#方法

    java调用com.google.guava 引入依赖 <dependency> <groupId>com.google.guava</groupId> <a ...