一.初始化Mariadb数据库

1.安装Mariadb

yum install mariadb mariadb-server

2.启动Mariadb

systemctl start mariadb
systemctl restart mariadb

3.初始化数据库

mysql_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, we'll need the current
password ``for` `the root user. If you've just installed MariaDB, and
you haven't ``set` `the root password yet, the password will be blank,
so you should just press enter here.Enter current password ``for` `root (enter ``for` `none): ``#当前数据库密码空的,直接回车
OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.Set root password? [Y``/n``] y  ``#设置root密码
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
ensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y``/n``] y  ``#禁止root远程登录``... Success!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``] y  ``#删除test数据库和对此数据库的访问权限``- Dropping ``test` `database...``... Success!``- Removing privileges on ``test` `database...``... Success!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 you've completed all of the above steps, your MariaDB
installation should now be secure.Thanks ``for` `using MariaDB!

4.登入数据库

mysql -uroot -p

二.数据库常用操作指令

登录                          mysql -uroot -p密码修改密码                   在安装路径的bin目录下进入cmd命令行,输入mysqladmin -uroot -p原密码 password 新密码退出数据库服务器     exit;创建数据库                create database test;(数据库名)查看所有数据库         show databases;选中某个数据库         use test;(数据库名)查看所有表                show tables;
查看数据表的结构          describe pet; / desc pet;(表名)删除数据表                     drop table user;(表名)删除数据库                     drop database test;(数据库名)补加主键约束             alter table client add primary key(name);删除主键约束             alter table client drop primary key;修改主键约束             alter table client modify id int primary key;
补加唯一约束             alter table user add unique(name);删除唯一约束             alter table client drop index name;修改唯一约束             alter table client modify name varchar(20) unique;查看是否自动提交      select @@autocommit;关闭自动提交             set autocommit = 0;手动提交事务             commit;回滚                           rollback;手动开启事务(1)        begin; + sql语句; (+ commit/rollback);手动开启事务(2)        start transaction; + sql语句; (+ commit/rollback);
事务的四个隔离级别:Read uncommitted(读未提交)
Read committed (读已提交)
Repeatable read (可重复读取) ———— Mysql 的默认隔离级别
Serializable (序列化、串行化)
事务隔离级别越高, 性能越差。查看事务的隔离级别           select @@global.transaction_isolation;修改隔离级别                      set global transaction isolation level read uncommitted;

三.远程连接数据库

首先要有Navicat Premium这个软件(链接里是白嫖的噢)

链接:https://pan.baidu.com/s/1sKIpLTt2Sy-qAmOTdOqncw 
提取码:kksk

Navicat premium是一款数据库管理工具,是一个可多重连线资料库的管理工具,它可以让你以单一程式同时连线到 MySQL、SQLite、Oracle、MariaDB、Mssql、及PostgreSQL 资料库,让管理不同类型的资料库更加的方便。

开始正文吧~~┗|`O′|┛

一、执行下面的命令允许Maria/MySQL的root用户远程连接,表示允许从任何主机连接到MariaDB/mysql服务器(这一步也就是用来给外部软件授权的)

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;(注意mypassword这个字段需要替换成你自己的MySQL/MariaDB登录密码)

二、激活阿里云服务器内部的MySQL/MariaDB数据库的权限,退出当前的数据库

FLUSH PRIVILEGES;  ---激活之前的权限配置
exit;或者quit;    ---退出数据库

到这一步,阿里云服务器里面的数据库的被外部访问的权限已经打开了

三、打开阿里云服务器的防火墙端口3306,而且这里是永久打开。服务器里面的其他软件的端口都是用这个方式打开的

systemctl start firewalld     ---打开/启动防火墙
firewall-cmd --zone=public --add-port=3306/tcp --permanent     ---打开防火墙的3306端口

四、重启一下防火墙,并查看刚刚配置的端口是否成功对外开放?

firewall-cmd --reload        #重启firewall
firewall-cmd --list-ports   #查看已经开放的端口

这样就可以使用远程连接了。其实大多数远程访问软件都是这个道理!!!!希望大家可以举一反三.┗|`O′|┛

初始化Mariadb数据库+远程连接数据库相关推荐

  1. Linux登陆Mariadb数据库,Mariadb数据库的远程连接(centos 7+ Navicat)

    在Linux服务器安装完MariaDB后,使用Navicat远程连接数据库时可能出现无法连接的情况. 一.未进行用户授权 该问题是因为mysql服务器没有对远程主机授权.mysql的授权的数据库是存放 ...

  2. MySQL Workbench 使用教程 - 如何使用 Workbench 操作 MySQL / MariaDB 数据库中文指南

    MySQL Workbench 是一款专门为 MySQL 设计的可视化数据库管理软件,我们可以在自己的计算机上,使用图形化界面远程管理 MySQL 数据库. 有关 MySQL 远程管理软件,你可以选择 ...

  3. MariaDB数据库——一款比Mysql数据库更优秀的数据库

    MariaDB数据库简介 MariaDB数据库是Mysql数据库的姊妹,它的使用方式与Mysql完全相同,而且MariaDB数据库的性能比Mysql更加优秀.MariaDB数据库与Mysql数据库的拥 ...

  4. centos中用C/C++语言连接MySQL/MariaDB数据库

    centos中用C/C++语言连接MySQL/MariaDB数据库 安装MariaDB 设置字符集(别管是什么,干就完事了) 设置远程链接MariaDB 上C语言 安装MariaDB yum inst ...

  5. Centos 7.2搭建MariaDB数据库服务器应用与管理

    安装MariaDB并实现启停控制 请关闭防火墙以及SElinux设置为disabled状态 使用yum命令进行安装mysql数据库 #yum -y install mariadb-server 启动m ...

  6. 《Linux就该这么学》培训笔记_ch18_使用MariaDB数据库管理系统

    <Linux就该这么学>培训笔记_ch18_使用MariaDB数据库管理系统 文章最后会post上书本的笔记照片. 文章主要内容: 初始化MariaDB服务 管理用户以及授权 创建数据库与 ...

  7. MariaDB数据库的备份和还原

    MariaDB数据库备份和还原 ------------------------------------------------------------------------------------ ...

  8. MariaDB数据库部署

    MariaDB数据库 · 数据库介绍 · MySQL与MariaDB · 数据库部署 1.安装MariaDB数据库 2.重启mariadb服务并加入开机启动项 3.!数据库初始化 4.设置防火墙策略 ...

  9. 在Linux虚拟机安装MariaDB数据库

    1. 下载MariaDB数据库 测试: 当前虚拟机是否可以正确的链接外网. 命令: [root@localhost src]# yum install mariadb-server 安装mariadb ...

最新文章

  1. 03.native方法(JNI)
  2. 为不同目录设置Forms身份验证
  3. C++基础-内存管理
  4. 修改npm全局安装模式的路径
  5. 写了一篇关于 NLP 综述的综述!
  6. 原生JavaScript轮播图效果实现
  7. 6421B Lab5 路由和远程访问的配置与故障排除
  8. 在自己的电脑上搭建服务器(可供对外访问)
  9. 乐橙tp6接入硬盘_乐橙“智能养殖”新概念,全套监管最佳组合方案曝光!
  10. 1.枚举类型、声明指针、常量、存储类型、运算符优先级记忆
  11. 洛谷 P2879 [USACO07JAN]区间统计Tallest Cow
  12. 线上支付之----网关支付、银联代扣通道、快捷支付、银行卡支付等网上常见支付方式接口说明!!
  13. 统计学中的三大相关系数
  14. React-native项目中如何使用阿里字体库呢?
  15. 西安无房证明网上办理指南
  16. 【已解决】 Unable to attach or mount volumes: unmounted volumes
  17. 机器学习方法:回归(三):最小角回归Least Angle Regression(LARS),forward stagewise selection
  18. 宝塔Linux面板命令大全(详细完整版)
  19. ITSM开源工具OTRS安装
  20. 六,基于FPGA的高速串行通信GTX知识梳理

热门文章

  1. [GKCTF 2021]babycat-revenge
  2. Xshell中文乱码
  3. 如何解决 could not open `E:\java\lib\amd64\jvm.cfg‘
  4. 书论27 唐太宗《论书》
  5. Java IO体系结构图
  6. 关于HTML滚动条问题
  7. MQTT服务器的安装
  8. mqtt服务器搭建php,百万级并发 之 MQTT 服务器
  9. SortedMap集合
  10. PATA 7-201 输出前n个英文大写字母