浙江省建设厅 网站是多少,移动互联网技术,页面设计在哪打开,中国设计联盟网创始人本文首发于 秋码记录
MariaDB 的由来#xff08;历史#xff09;
谈起新秀MariaDB#xff0c;或许很多人都会感到陌生吧#xff0c;但若聊起享誉开源界、业界知名的关系型数据库——Mysql#xff0c;想必混迹于互联网的人们#xff08;coder#xff09;无不知晓。
其…本文首发于 秋码记录
MariaDB 的由来历史
谈起新秀MariaDB或许很多人都会感到陌生吧但若聊起享誉开源界、业界知名的关系型数据库——Mysql想必混迹于互联网的人们coder无不知晓。
其实mariaDB是由Mysql分支出来的一个项目而且同属于同一个作者Michael Widenius。或许你会纳闷既然Mysql如此优秀作者而又为什么再次创造出一个新的数据库呢
谈起mariadb的诞生那就不得不说Mysql那命运多舛的际遇咯起初Mysql以开源的形式瞬间火爆互联网圈这其中就包括创造出 Java 的公司—— sun彼时的他们亟需一套小巧且功能强大的数据库来摆脱其他商业化数据库。故而sun 公司看准了时机斥巨资收购了彼时还处在蓬勃发展的Mysql。
时间一晃来到了2009年号称全球数据库巨头 Oracle以当时看来是天价的价格收购了sun 公司作为sun 公司的附庸品当然也卖身到新雇主Mysql再次改投公司并非它所愿实是无奈之举。
倘若sun 公司没被Oracle收购或许不会出现mariaDB毕竟sun 公司创造出了java这一从它诞生以来稳居于年度 program language编程语言排行榜前三毫不夸张的说它影响了一代的互联网的进程。
可事与愿违sun 公司终将被oracle 公司收购了。自打oracle公司并购了sun 公司全球数以千万计的Java Engineer便开始为Java是否还会开源起了忧虑之心。
果不其然oracle 公司还是向java开刀了他们修改了java的一些开源策略如商业授权……
也正源于此作为Mysql的作者不得不为mysql的未来而担忧。然而现在的mysql已经属于Oracle 公司看似开源出来但Oracle 公司随时都有可能将它闭源化。可他唯一能做的就是从开源的mysql开出一个分支构建出一个新的数据库而它将改进Mysql所出现的问题虽然mariadb是由mysql作者主导的但主要还是靠开源社区来贡献代码。
安装前准备
我们知道大多数开源软件多多少少会使用第三方开源工具类库软件包。虽然你的项目大可不必依赖第三方类库完全由自己着手编码来实现那也是没问题但在编写完这些工具库时你的项目引入之前你总得为你所编写的类库做unit test吧
工具类库代码量不是非常庞大的话由你自己编写亲自做unit test这都没什么毕竟自己从零开始实现一个与第三方相似的工具类库给自己带来的不单单是一种炫技感更多的是成就感、喜悦感。
可倘若工具类库代码行数达到上万甚至十来万行呢此时的你再想从头写起与第三方类库类似的功能怕是力不从了吧且不说编写那十来万行的代码所消耗的时间而是在接下来的事是需要对它做unit test将会让你开始怀疑人生。
一个开源项目/产品能赢得越来越多用户的追捧其中最为重要的一点莫过于产品的迭代更新速度是否快于竞争对手/友商。
为了能使产品在迭代更新上快于他人产品的研发团队往往会将项目中公共模块抽取出来形成一个工具类库或是使用了第三方开源类库从而降低了花在这上面的时间以及精力4以便能够全身心的着眼于产品本身。
安装所需的软件包
至于安装mariaDB前为何要安装software-properties-common这个软件包呢其实你也是可以不安装这个依赖库而是直接安装MariaDB那也是没问题的只是在安装MariaDB过程中会出现Error最终导致无法正常的安装MariaDB而出现错误的原因却是当前Linux发行版还未安装某个软件包。
为了使MariaDB能够继续的安装下去你便按照error提示安装MariaDB所需的第三方类库。
既然是这样的话我们何不将MariaDB所需的软件包提前安装呢
apt install software-properties-common -y添加 MariaDB 镜像仓库
无论你当前系统属于哪个Linux 发行版使用在线安装软件时总是会在当前系统的镜像库搜寻以此来下载软件。
当然咯系统里的镜像仓库的软件版本或许有些旧毕竟某些软件更新迭代快以至于Linux 发行版来不及去更新镜像仓库内的软件版本。
故而我们可以将需要下载哪个版本的MariaDB添加到系统镜像仓库里面。
至于那个MariaDB key 是官方所要求的你将它下载下来就对咯
apt-key adv --fetch-keys https://mariadb.org/mariadb_release_signing_key.asc
sudo add-apt-repository deb [archamd64,arm64,ppc64el] https://mirrors.ustc.edu.cn/mariadb/repo/10.6/ubuntu bionic main 安装 mariadb-server 和 mariadb-client
热身的差不多了是该真正露出本领的时刻了此处应有振聋发聩的掌声不绝于耳的那种掌声。
使用以下命令来安装MariaDB的server和client。
apt install mariadb-server mariadb-client设置 Mariadb 的安全信息
在安装完MariaDB后我们需要对它做些必要性的安全措施比如root密码、是否使用unix socket登陆、是否开启远程登陆……
mariadb-secure-installationmariaDB的root密码默认是空所以在出现这句Enter current password for root (enter for none):提示时你就直接按键盘上的Enter也就是回车键。
随后的Switch to unix socket authentication [Y/n]便是询问你是否开启unix socket 认证。
紧接着一句Change the root password? [Y/n]问你是否改变root密码毫无疑问root密码是需要修改的
接下来的便是Remove anonymous users?[Y/n] 这么一句它问你是否移除匿名用户。
之后的一句Disallow root login remotely? [Y/n]n则是是否禁止 root 远程登陆。
再者便是Remove test database and access to it? [Y/n]征求你是否需要移除test 数据库和数据的许可。
尾随其后的Reload privilege tables now? [Y/n] Y还是寻求你是否现在来重新加载 privilege表以此来更新你上述所做的修改。
root0XXX:~# mariadb-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, well need the current
password for the root user. If youve just installed MariaDB, and
havent set the root password yet, you should just press enter here.
Enter current password for root (enter for none): #直接按 Enter 键
OK, successfully used password, moving on...
Setting the root password or using the unix socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer n.
Switch to unix socket authentication [Y/n] Y
Enabled successfully!
Reloading privilege tables..
... Success!
You already have your root account protected, so you can safely answer n.
Change the root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
...Success!
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
nsures that
someone cannot guess
the root
password from the
network.
Disallow root login remotely? [Y/n]n
... skipping.
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] n
... skipping.
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 youve completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
rootXXX:~#查看 Mariadb 服务状态
我们可以使用以下命令来查看当前MariaDB服务的状态虽然目前我们知道MariaDB正处于running中。
systemctl status mariadb我们从下面的输出信息也是可以看出当前的MariaDB服务正处于running中。
rootXXX:~# systemctl status mariadb
* mariadb.service - MariaDB 10.6.15 database serverLoaded: loaded (/1ib/systemd/system/mariadb.service; enabled; vendor preset:enabled)Drop-In: /etc/systemd/system/mariadb.service.d|_migrated-from-my.cnf-settings.confActive: active (running) since Sat 2024-08-31 15:03:05 08; 22min agoDocs: man:mar1adbd(8)https://mariadb.com/kb/en/library/systemd/
Main PID: 701 (mariadbd)Status: Taking your SQL requests now...Tasks: 8 (limit:4915)CGroup: /system.slice/mariadb.service|_701 /usr/sbin/mariadbd
Aug 31 15:03:05 vps74437279.hosteons.com mariadbd[701):2024-08-31 15:03:05 0 [Note]InnoDB: File./ibtmpl size is now 12 MB.
Aug 31 15:03:05 vps74437279.hosteons.com mariadbd[701]: 2024-08-31 15:03:05 0 [Note]
InnoDB: 10.6.15 started; log sequence number 42114; transaction id 14
Aug 31 15:03:05 vps74437279.hosteons.com mariadbd[701]: 2024-08-31 15:03:05 0[Note] PluginFEEDBACK is disabled.
Aug 31 15:03:05 vps74437279.hosteons.com mariadbd[701]: 2024-08-31 15:03:05 0[Note)
InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib buffer pool
Aug 31 15:03:05 vps74437279.hosteons.com mariadbd[701): 2024-08-31 15:03:05 0 [Note] InnoDB: Buffer pool(s) load completed at 240831 15:03:05
Aug 31 15:03:05 vps74437279.hosteons.com mariadbd[701]:2024-08-31 15:03:05 0[Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-sec
Aug 31 15:03:05 vps74437279.hosteons.com mariadbd[701]:2024-08-31 15:03:05 0[Note] Server socket created on IP:127.0.0.1.
Aug 31 15:03:05 vps74437279.hosteons.com mariadbd[701):2024-08-31 15:03:05 0 [Note] /usr/sbin/mariadbd: ready for connections.
Aug 31 15:03:05 vps74437279.hosteons.com mariadbd[701]:Version: 10.6.15-MariaDB-1:10.6.15maria~ubu1804socket: /run/mysqld/mysqld.sockport: 3306mariadb.org b
Aug 31 15:03:05 vps74437279.hosteons.com systemd[1]: Started MariaDB 10.6.15 database server.
lines 1-23/23 (END)设置开机自启动
systemctl enable mariadb查看 mariadb 版本
当你在Terminal输入mysql -u root -p的时候你的脑袋是不是有那么一瞬间的迷糊不禁纳闷“我明明安装的是MariaDB怎么会去使用mysql的命令呢”
对于你的疑惑作为MariaDB非官方人员的我给出了这样的解释
1、上面有讲到MariaDB是由mysql分支而来的难免有些命令还在使用mysql。2、或许他们懒得将mysql命令修改成mariaDB了毕竟MariaDB这都更新迭代了多少个版本要改的话早就改了。或许是旧版本还没改新版本可能改了也未可知。
mysql -u root -p添加用户及授权
grant all privileges on *.* to root% identified by YourPasswd;
flush privileges;