最近在CentOS7上安装了MariaDB数据库,Maria数据库是与MySQL数据库兼容的
以此文章记录一下安装过程,大部分命令都是官网上有的,不多说直接上命令:
1.用yum安装
安装
命令:sudo yum install mariadb-server
配置(输入这个命令后会有下面的交互过程)
命令:mysql_secure_installation
是否设置root密码
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
是否删除匿名用户
Remove anonymous users? [Y/n] y
是否禁止root远程登录
Disallow root login remotely? [Y/n] y
是否删除test数据库
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
是否重新加载权限表
Reload privilege tables now? [Y/n] y
... Success!
2.登陆
输入mysql
输出
[root@common-server ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
3.开启和关闭
启用MariaDB以在启动时启动:
systemctl enable mariadb
启动服务:
systemctl start mariadb
关闭服务:
systemctl stop mariadb
4.使用
和MySQL的使用方法一样
例如:
修改密码
命令: set password = password("123456");
输出:Query OK, 0 rows affected (0.00 sec)
显示所有数据库
命令: show databases;
输出:
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
5.另附MySQL的安装语句
安装:
yum install mysql-community-server
启动:
systemctl start mysqld
显示状态:
systemctl status mysqld
网友评论