Ubuntu 16 MariaDB 开启远程访问
来源:互联网 发布:网络道德 编辑:程序博客网 时间:2024/06/16 20:10
前言:
在Ubuntu16上安装MariaDB后, 只能在本地访问, 不能在windows中通过navicat远程访问, 一直提示错误:
Can't connect to MySQL server on 192.168.x.xxx (Unknown error: 10061)
本文记录下解决过程。
首先感谢这位博主给我的启发, 虽然Mysql和Maria很像, 部分配置任然不同.
http://blog.csdn.net/SCTU_vroy/article/details/53019198
解决思路
1. 确定Mysql服务已开启
$ service mysql status// 服务已开启 Active: active● mysql.service - LSB: Start and stop the mysql database server daemon Loaded: loaded (/etc/init.d/mysql; bad; vendor preset: enabled) Active: active (running) since Thu 2017-09-28 15:39:41 ULAST; 25min ago ...// 服务未启动状态 Active: inactive● mysql.service - LSB: Start and stop the mysql database server daemon Loaded: loaded (/etc/init.d/mysql; bad; vendor preset: enabled) Active: inactive (dead) since Thu 2017-09-28 16:06:52 ULAST; 6s ago ...
开启mysql服务
$ service mysql start==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===Authentication is required to start 'mysql.service'.Authenticating as: nginx,,, (nginx)Password: ==== AUTHENTICATION COMPLETE ===
2. 在mysql.user表中添加新用户(与linux用户无关), 配置好相关权限
进入 Maria 数据库, 先看看已有用户以及数据库有哪些
// 使用管理员进入数据库$ sudo mysql -uroot -p// 查看当前已存在用户MariaDB [(none)]> select host,user from mysql.user;+-----------+-------+| host | user |+-----------+-------+| % | admin || % | root || localhost | root |+-----------+-------+// 查看已有数据库MariaDB [(none)]> show databases;+--------------------+| Database |+--------------------+| information_schema || my_test || mysql || performance_schema |+--------------------+
接下来在mysql.user
表中添加一个新用户, 示例添加一条dbadmin
用户, 创建新的数据库my_db
, 并为dbadmin配置权限: 拥有my_db
库所有权限(一般来说dba不会把root开放给我们).
// 创建数据库, 这里作为演示, 简单创建MariaDB [(none)]> create database `my_db`;MariaDB [(none)]> show databases;+--------------------+| Database |+--------------------+| information_schema || my_db || my_test || mysql || performance_schema |+--------------------+// 创建新用户// dbadmin: 新用户登录名 mysql.user.user// sqlpass: 新用户登录密码 mysql.user.password// % : 无限制链接地址 mysql.user.hostMariaDB [(none)]> create user 'dbadmin'@'%' identified by 'sqlpass';MariaDB [(none)]> select host,user from mysql.user where user='dbadmin';+------+---------+| host | user |+------+---------+| % | dbadmin |+------+---------+// 为用户分配权限// 完全控制 my_db// my_db.*: my_db库中的所有表MariaDB [(none)]> GRANT ALL PRIVILEGES ON my_db.* TO 'dbadmin'@'%';// 权限分配完成后一定要记得刷新// 否则不会生效MariaDB [(none)]> flush privileges;
到这如果防火墙和Maria配置没问题的话, 已经可以远程访问了. 如果还是不能远程访问, 继续往下看.
3.检查防火墙配置
两种解决方案: a 关闭防火墙; b. 为3306放行
// 关闭防火墙# ufw disable# ufw statusStatus: inactive// 开启防火墙// 为3306放行# sudo ufw allow 3306# ufw enable# ufw statusStatus: activeTo Action From-- ------ ----3306 ALLOW Anywhere 3306 (v6) ALLOW Anywhere (v6)
4. 检查 .conf 配置, 修改配置文件后要重启生效
配置文件位置与Mysql略有不同.
- MySQL配置文件位置: /etc/mysql/mysql.conf.d/mysqld.cnf
- MariaDB配置文件位置: /etc/mysql/mariadb.conf.d/50-server.conf
# cd /etc/mysql/mariadb.conf.d# lltotal 24drwxr-xr-x 2 root root 4096 Sep 28 15:38 ./drwxr-xr-x 4 root root 4096 Sep 27 19:08 ../-rw-r--r-- 1 root root 495 Jul 1 05:26 50-client.cnf-rw-r--r-- 1 root root 336 Jul 1 05:26 50-mysql-clients.cnf-rw-r--r-- 1 root root 321 Jul 1 05:26 50-mysqld_safe.cnf-rw-r--r-- 1 root root 3492 Sep 28 15:38 50-server.cnf
修改 50-server.conf 文件 (vim 显示行号 : set number/nonumber), 找到 bind-address = 127.0.0.1
这一行, 并注释掉(前面插入井号:#)
# vim 50-server.conf 22 datadir = /var/lib/mysql 23 tmpdir = /tmp 24 lc-messages-dir = /usr/share/mysql 25 skip-external-locking 26 27 # Instead of skip-networking the default is now to listen only on 28 # localhost which is more compatible and is not less secure. 29 # bind-address = 127.0.0.1 30 31 # 32 # * Fine Tuning 33 # 34 key_buffer_size = 16M
如有错误, 欢迎指正探讨.
阅读全文
0 0
- Ubuntu 16 MariaDB 开启远程访问
- Ubuntu mysql 开启远程访问
- ubuntu mysql开启远程访问
- mariadb 远程访问
- Ubuntu中开启MySQL远程访问功能
- ubuntu下开启远程访问mysql
- Ubuntu开启mysql远程访问权限
- ubuntu安装mysql并开启远程访问
- ubuntu 开启mysql远程访问服务的方法
- 开启SSH服务,让安卓手机远程访问 Ubuntu 14.04
- ubuntu下开启mysql的允许远程访问
- Ubuntu Linux中开启MySQL远程访问功能的方法
- Ubuntu Linux中开启MySQL远程访问功能
- Ubuntu下开启Mysql远程访问的方法
- Ubuntu Linux中开启MySQL远程访问功能
- Windows2008开启远程访问
- MySQL开启远程访问
- mysql 开启远程访问
- C#梳理【反射Reflection】
- 阿里云何万青:搭建首个全球云上超算中心_做超算能力的普惠者
- synchronized关键字知多少
- 【android】几个和密码相关的问题分析(开机密码输入无效、FDE后改变密码无效、FDE后解密失败)
- HDU 1025 Constructing Roads In JGShining's Kingdom (简单dp, 最长上升子序列LIS)
- Ubuntu 16 MariaDB 开启远程访问
- NSGA-II 学习笔记
- CSS预处理工具Stylus
- 2017南宁网络赛 I. GSM Base Station Identification 暴力
- 8句话送给您
- linux下openssl 安装
- ZooKeeper 常用操作API详解
- leetcode: 371. Sum of Two Integers
- Excel 单元格中插入附件