一、MySQL在Centos7中的应用

一、Centos7系统中的MariaDB 数据库

        CentOS 7/RHEL7中,默认已经不再提供mysql的安装源,取而代之的是mysql的原开发者另起炉灶开发的MariaDB 数据库,MariaDB 是MySQL的一个分支,从MySQL被甲骨文收购之后开发的一个替代品,不仅完全兼容mysql而且比mysql更加强大。

   1、首先需要安装  MariaDB 数据库    

      输入命令:      sudo  yum install mariadb-server

   2、安装完成后,需启动数据库

           命令:systemctl start madiadb

注:Systemctl是一个systemd工具,主要负责控制systemd系统和服务管理器。

查看数据库状态 :systemctl status mariadb     

systemctl start mariadb       //启动
systemctl restart mariadb    //重启
systemctl stop mariadb        //停止
systemctl reload mariadb     //重新加载
systemctl status mariadb     //查看状态
systemctl enable mariadb     //开机自启动
systemctl is-enabled mariadb     //查询是否彭重为开机自启动
systemctl disable mariadb     //取消开机自启动
systemctl mask  mariadb      //禁用
systemctl unmask mariadb    //取消禁用

  3、数据库启动以后,就可以进入MySQL

 输入命令: mysql -h(主机名或者主机IP )-u(用户名) -p(用户密码)

eg:   mysql -uroot -p

注:第一次登录一般都是没有密码,有密码的话为  toor

[root@localhost ~]# mysql -uroot       //第一次登录使用没有密码,所以没有 -p 项
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 5.5.68-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

 

posted @ 2021-03-10 11:27  chao_xiong  阅读(204)  评论(0)    收藏  举报