欢迎投稿

今日深度:

Centos下MySQL(Mariadb)的安装,centosmariadb

Centos下MySQL(Mariadb)的安装,centosmariadb


  • Mariadb的安装

因为Centos默认的数据库是Mariadb,所以安装很简单,只需要使用yum安装即可。

[root@bogon ~]# yum -y install mariadb-server mariadb
[root@bogon ~]# rpm -qi mariadb   #查看是否安装成功

解释:mariadb只是client客户端,mariadb-server才是mariadb的后台数据库。

还有一点,在Centos中,执行yum -y install mysql mysql-server其实安装的是mariadb。

启动mariadb并加入开机自启

[root@bogon ~]# systemctl start mariadb
[root@bogon ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@bogon ~]# 

登录mariadb。

首次安装,mariadb的密码默认为空,所以输密码时直接敲回车就行。还有一点要注意:mariadb的命令和mysql的命令几乎一模一样。

[root@bogon ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

  • MySQL的安装

首先查看是否安装了mariadb

[root@bogon ~]# rpm -q mariadb
mariadb-5.5.60-1.el7_5.x86_64
[root@bogon ~]# 

若安装了,卸载掉

[root@bogon ~]# rpm -q mariadb

接下来安装MySQL

因为Centos默认的数据库是mariadb,所以yum源里是没有安装包的,要去官网上下载。

链接:

https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

[root@bogon ~]# wget  https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

安装MySQL的rpm包

[root@bogon ~]# rpm -ivh mysql57-community-release-el7-11.noarch.rpm 

查看是否安装成功

[root@bogon ~]# rpm -q mysql57-community-release 
mysql57-community-release-el7-11.noarch

安装MySQL

[root@bogon ~]# yum -y install mysql-server

现在执行这条命令安装的才是MySQL,不是mariadb

启动MySQL并加入开机自启

[root@localhost ~]# systemctl start mysqld
[root@localhost ~]# systemctl enabl mysqld

登录MySQL。和mariadb一样,首次登录密码默认为空

[root@localhost ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

ok,MySQL|mariadb的安装就完成了。

www.htsjk.Com true http://www.htsjk.com/mariadb/25842.html NewsArticle Centos下MySQL(Mariadb)的安装,centosmariadb Mariadb的安装 因为Centos默认的数据库是Mariadb,所以安装很简单,只需要使用yum安装即可。 [root @bogon ~] # yum -y install mariadb-server mariadb [root @bogon ~] #...
相关文章
    暂无相关文章
评论暂时关闭