本文建议横屏阅读,效果更佳(本文涉及到的链接见文章最后)
MySQL 8.0 a lot of new . These make MySQL much more (like new , and , …) and fault (new data ), more (new redo log , less , scale out of , …), (SQL Roles, add ), many (but many!) and group … and many cool stuff like the new Store, the new MySQL Shell and MySQL that you know if you this blog (see 10 for for 10 for DBAs & OPS).
.0带来了很多新特性。这些新特性使得MySQL数据库更加安全(例如新的认证方式,安全的密码策略和管理方式,...)和容错(新的数据字典)功能更强大(新的redo设计postfix,争用更少,极度扩展,…),更好的操作管理(SQL角色,即时添加列 ),很多(其实真的很多)复制增强和本地组复制...最后还有很多很酷的东西例如文档存储,全新的MySQL Shell和MySQL ,如果你看过以下这些博客的话你应该已经知TOP 10 for for 道了(TOP 10 for for 和TOP 10 for DBAs & OPS)
不再是替代者
We saw in this post how to from 5.5 ( on / 7) to MySQL. This was a as at the time was a drop in for MySQL…but this is not the case since 10.x !
我们在上一篇文章中看到了如何从 5.5(在/上默认)迁移到MySQL。这是一个直接的迁移,因为当时是MySQL的替代者…但是从 10.x开始情况就不一样了。
让我们开始迁移到.0
选项
Two are to us:
我们有两种方式:
准备迁移
方式1-全部逻辑导出
It’s to avoid to have to deal .* are they won’t be , I you to save all that and the like users . It’s maybe the best time to do some .
最好不要迁移mysql.*这些表,因为它们不兼容,我建议你保存所有的信息并且手动导入需要的条目例如用户表。这可能是做一些清理的最佳时机。
As we are still using our site to this . I will dump :
我们仍然使用我们的网站来演示迁移。我将导出wp数据库:
mysqldump -B wp> wp.sql
doesn’t , so I used the good . There was a nice this about MySQL dump ,see it here
没有提供,所以我们使用了。这里有一篇很好的关于MySQL逻辑导出解决方案的文章,请看这里(参考链接一)
方式2-表结构导出 & 表传输
First we take a dump of our the data (-d):
首先我们只导出数据库结构
mysqldump -d -B wp > wp_nodata.sq
Then we the first table space:
然后我们导出第一个表空间
[wp]> flush tables wp_comments for export;
Query OK, 0 rows affected (0.008 sec
We copy it to the (the. the.cfg):
我们将其拷贝到所需的位置(.ibd和.cfg)
cp wp/wp_comments.ibd ~/wp_innodb/
cp wp/wp_comments.cfg ~/wp_innodb/
And we the table:
最后,我们解锁表
[wp]> unlock tables;
These above need to be for all the ! If you have a large of table I you to all these .
以上这些操作需要为每个表都重复做一次!如果你有很多表,我建议你使用脚本来做这些操作
替换二进制文件/安装MySQL 8.0
, if we MySQL from the Repo as seen on this post, MySQL 8.0 won’t be seen as a for 10.x. To avoid any and , we will the by the MySQL ones using ofyum:
与以前的版本不同,如果我们从社区网站上安装MySQL,.0将不会被视为 10.x兼容替代者。为了避免任何不兼容和安装失败,我们将使用yum swap的命令来将MySQL包替换的包
yum swap --install mysql-community-server mysql-community-libs-compat --remove MariaDB-server MariaDB-client MariaDB-common MariaDB-compat
This new yum is very , and allow other like php-mysql or for to stay some
这个新的yum命令非常有用,并且允许其他依赖项(如php-mysql或)保持安装而不会破坏某些依赖项
The of the will be to:
这个命令的结果类似于
Removed:
MariaDB-client.x86_64 0:10.3.13-1.el7.centos
MariaDB-common.x86_64 0:10.3.13-1.el7.centos
MariaDB-compat.x86_64 0:10.3.13-1.el7.centos
MariaDB-server.x86_64 0:10.3.13-1.el7.centos
Installed:
mysql-community-libs-compat.x86_64 0:8.0.15-1.el7
mysql-community-server.x86_64 0:8.0.15-1.el7
Dependency Installed:
mysql-community-client.x86_64 0:8.0.15-1.el7
mysql-community-common.x86_64 0:8.0.15-1.el7
mysql-community-libs.x86_64 0:8.0.15-1.el7
Now the best is to empty the and :
现在最好清空然后启动:
rm -rf /var/lib/mysql/*
systemctl start mysql
This will start the and start MySQL.
As you may know, by MySQL is now more and a new has been to . You can find it in the error log (/var/log/.log):
这将会开始初始化进程然后启动MySQL
你可能知道postfix,默认情况下,MySQL现在更加安全,并且已为root用户生成密码。你可以在错误日志(/var/log/.log)中找到它:
2019-03-26T12:32:14.475236Z 5 [Note] [MY-010454] [Server]
A temporary password is generated for root@localhost: S/vfafkpD9a
At first login with , the must be :
第一次使用root用户登录,必须更改密码:
mysql -u root -p
mysql> set password='Complicate1#'
添加凭据
Now we need to our (wp), our user and its .
现在我们需要创建我们的数据库(wp),我们的用户及其密码
, note that the PHP used by in might now be yet with the new , we will have to our user with the older ,d. For more info see these posts:
请注意,中默认使用的PHP版本现在可能与新的默认安全认证插件不兼容,因此我们必须使用旧的认证插件创建我们的用户d。有关更多信息,请参阅以下帖子
mysql> create user 'wp'@'127.0.0.1' identified with
'mysql_native_password' by 'fred';
by , this (fred) won’t be with the .
To not have to our , it’s to the like this:
默认情况下,这个密码(fred)不会被默认的密码策略通过。为了不修改我们的程序,可以通过下面的命令来覆盖策略:
mysql> set global validate_password.policy=LOW;
mysql> set global validate_password.length=4
It’s to see the user and its using the query:
可以通过如下sql很轻松地查看用户及相应的认证插件
mysql> select Host, User, plugin,authentication_string from mysql.user where User='wp';
+-----------+------+-----------------------+-------------------------------------------+
| Host | User | plugin | authentication_string |
+-----------+------+-----------------------+-------------------------------------------+
| 127.0.0.1 | wp | mysql_native_password | *6C69D17939B2C1D04E17A96F9B29B284832979B7 |
+-----------+------+-----------------------+-------------------------------------------+
We can now the and grant the to our user:
现在我们可以创建数据库并授权给我们的用户:
mysql> create database wp;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on wp.* to 'wp'@'127.0.0.1';
Query OK, 0 rows affected (0.01 sec)
恢复数据
This is also by the .
此过程也由前面的选择而定
方式1
This , is the most , one and our site is back :
这个方式最直接,一次还原然后我们的网站重新上线:
mysql -u wp -pfred wp <~/wp.sql
方式2
This is more as it more steps.
First we will have to all the with no data:
这个方式相对来说更复杂因为它需要更多步骤
首先我们需要先恢复结构
mysql -u wp -pfred wp <~/wp_nodata.sql
And now for every we need to the :
然后,对于每张表我们需要进行如下操作
mysql> alter table wp_posts discard tablespace;
cp ~/wp_innodb/wp_posts.ibd /var/lib/mysql/wp/
cp ~/wp_innodb/wp_posts.cfg /var/lib/mysql/wp/
chown mysql. /var/lib/mysql/wp/wp_posts.*
mysql> alter table wp_posts import tablespace
Yes, this is for all , this is why I you to it if you this .
是的,所有的表都需要这么操作,所以这也是为什么我建议你使用脚本来跑如果你选择了这种方式的话
结论
So as you could see, it’s still to from to MySQL but since 10.x, this is not a drop in and steps .
正如你看到的,仍然可以从迁移到MySQL,但是从10.x开始,它不再是作为替代者进行删除,而是需要包括逻辑备份几个步骤。
补充链接:
TOP 10 for for :
TOP 10 for DBAs & OPS:
参考链接一:
参考链接二:
参考链接三:
参考链接四:
参考链接五:
欢迎大家关注Java公众号,一起探讨
30天打卡活动:
第九期30天打卡赠书和红包活动,今天正式启动! 最近热文:
1、别总写代码,这130个网站比涨工资都重要 2、如何设计一个高性能短链系统? 3、喜大普奔!GitHub 官方 App 正式版首发! 4、同样用Vim编辑器,为什么别人比你更高效? 5、有了这 4 款工具,老板再也不怕我写烂SQL了 6、【限时免费】加入我们的社群!
限时特惠:本站持续每日更新海量各大内部创业课程,一年会员仅需要98元,全站资源免费下载
点击查看详情
站长微信:Jiucxh