新安装mariadb远程登陆配置及相关问题排查
前言:
安装过程不再赘述,直接说问题,mysql的远程连接需要解决两个问题:1.允许root用户远程连接。2.允许任意ip远程连接数据库。当然,在测试和解决问题之前,得首先保证你的数据库与远程主机之间的网络通信没有问题,简单的来说,就是互相ping通,其次,为了避免防火墙的干扰,将本地主机和数据库主机的防火墙都关闭,当然,生产环境下防火墙肯定是要打开的,并且需要额外的安全配置。
问题解决:
1.新安装的数据库默认是需要初始化的,在数据库服务启动的情况下,使用下面的命令来进行初始化。
[root@localhost ~]# mysql_secure_installation
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]
... 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] n #如果是为root用户配置远程登陆,这里需要选择n,不选择禁止root用户远程登陆,别的选择都无关紧要。
... 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]
- 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]
... 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!
[root@localhost ~]# systemctl restart mariadb #完成初始化之后,重启服务。
2.允许root用户远程连接与允许任意ip远程连接数据库都是可以通过在数据库里执行一条命令来实现的。
这里分为两种情况:
1)新建admin用户远程连接mysql数据库(新建任意用户,以admin为例)
grant all on *.* to admin@'%' identified by '' with grant option;
flush privileges;
允许任何ip地址(%表示允许任何ip地址)的电脑用admin帐户和密码(123456)来访问这个mysql server。
注意admin账户不一定要存在。
2)支持root用户允许远程连接mysql数据库
grant all privileges on *.* to 'root'@'%' identified by '' with grant option;
flush privileges;
需要注意的是,为root用户配置远程登陆,密码需要和之前配置的密码一致。
3.ubuntu系统的额外配置。
Ubuntu系统的my.cnf文件在vim /etc/mysql/mysql.conf.d/mysqld.cnf中,注释掉其中的
bind-address = 127.0.0.1
centos系统的配置文件中默认没有该行。
检查的办法也很简单,在数据库启动的前提下,使用netstat -an | grep 3306查看端口的连接信息。0.0.0.0则表示允许任意IP连接。
如图所示则为允许任意IP连接。
新安装mariadb远程登陆配置及相关问题排查的更多相关文章
- CentOS 7安装MariaDB 10详解以及相关配置
第一步:添加 MariaDB yum 仓库 首先在CentOS操作系统中/etc/yum.repos.d/目录下添加 MariaDB 的YUM配置文件MariaDB.repo文件. vi /etc/y ...
- nvcatmysql安装注册流程以及远程登陆配置步骤
前言:网络上下载工具良莠不齐,找到合适的比较困难.因为nvcat回收了网络上的大部分注册码,这个nvcatformysql下载到可以破解的费了点时间,最后经过配置成功远程登陆到mysql,在此记录一下 ...
- 安装MariaDB和简单配置
1.安装MariaDB 安装命令 yum -y install mariadb mariadb-server 安装完成MariaDB,首先启动MariaDB systemctl start maria ...
- CentOS 7.0 使用 yum 安装 MariaDB 及 简单配置
1.安装MariaDB 安装命令 yum -y install MariaDB-server MariaDB-client 安装完成MariaDB,首先启动MariaDB 设置开机启动 接下来进行Ma ...
- Oracle客户端的安装与远程连接配置
在继续Oracle客户端的安装之前,需要分析一下Oracle客户端与数据库服务器之间的连接机制. 一.Oracle客户端与服务器端的通讯机制 1.Oracle Net协议 如下图所示,Oracle通过 ...
- [转载]Windows 2008多用户同时远程登陆配置方法
有些朋友需要在在使用Windows 2008远程登录功能时,进行多用户登录,那么就可以采用以下配置方法: 首先要启用远程桌面这一功能:右击"我的电脑"→ 属性 → 远程配置 → 远 ...
- Windows版本搭建安装React Native环境配置及相关问题
此文档整理参考地址: http://www.lcode.org/%E5%8F%B2%E4%B8%8A%E6%9C%80%E8%AF%A6%E7%BB%86windows%E7%89%88%E6%9C% ...
- MariaDB远程连接配置
由于MariaDB是由MySQL的一个分支发展起来的,二者的配置也大体相同. wex@localhost:~# mysql -uroot -proot 进入MariaDB服务器,将mysql.user ...
- 树莓派 wheezy安装与远程登录配置
一.准备工作 1:wheezy系统镜像 2:Win32DiskImager-0.9.5-install 3:SDFormatter 4:SD卡 我用的是8G 二.安装系统 流程:SDFormatter ...
随机推荐
- Roarctf 几道pwn 复现
1.easy_pwn 可以利用的点: __int64 __fastcall sub_E26(signed int a1, unsigned int a2) { __int64 result; // r ...
- Navicat Premium 12连接ubuntu18 ,Mysql 5.7.27-0
1,搭建好mysql服务器,cd /etc/mysql/mysql.conf.d,进入mysql配置目录,vim mysqld.cnf 2,注释掉,bind-address =127.0.0.1 , ...
- 【Luogu P1265】公路修建
Luogu P1265 本来一开始我用的Kruskal--但是由于double类型8字节,所以MLE了. 很容易发现这是一道最小生成树的题目. 值得注意的是题目中给的第二个限制,只存在唯一情况即这个环 ...
- linux下的du和df的区别
du(disk usage)是通过搜索文件来计算每个文件的大小然后累加,du能看到的文件只是一些当前存在的,没有被删除的.他计算的大小就是当前他认为存在的所有文件大小的累加和. df(disk fre ...
- 移动端App uni-app + mui 开发记录
前言 uni-app uni-app是DCloud推出的终极跨平台解决方案,是一个使用Vue.js开发所有前端应用的框架,官网:https://uniapp.dcloud.io/ mui 号称最接近原 ...
- [ch04-02] 用梯度下降法解决线性回归问题
系列博客,原文在笔者所维护的github上:https://aka.ms/beginnerAI, 点击star加星不要吝啬,星越多笔者越努力. 4.2 梯度下降法 有了上一节的最小二乘法做基准,我们这 ...
- Chapter 01—Introduction to R
1.getwd():list the current working directory. (即获得当前工作路径) 2.setwd("mydirectory"):change th ...
- 安装PHP5和PHP7
5月25日任务 课程内容: 11.10/11.11/11.12 安装PHP511.13 安装PHP7php中mysql,mysqli,mysqlnd,pdo到底是什么http://blog.csdn. ...
- num += num 与 num = num+ num
a = 100def test(num): num += num print(num) test(a)print(a) 200100 这里 num += num 与 num = num+ num 不能 ...
- php方法注释
注释格式 <?php /** * @method 发送邮件 * @url email/send?token=xxx * @http POST * @param token string [必填] ...