zoukankan      html  css  js  c++  java
  • Ubuntu安装MariaDB教程

    一、环境

    • 服务器:Ubuntu 16.04.1 LTS(GUN/Linux 4.4.0-91-generic x86_64)
    • 数据库版本:MariaDB 10.3

    二、安装流程

    2.1 进入MariaDB 网站

    https://downloads.mariadb.org/mariadb/repositories/#mirror=neusoft该地址中,可以查找对应系统的安装命令配置。

    2.2 设置MariaDB 仓库

    默认上MariaDB的包并没有在Ubuntu仓库中。要安装MariaDB,我们要设置MariaDB仓库。

    sudo apt-get install software-properties-common
    sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
    sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mirrors.neusoft.edu.cn/mariadb/repo/10.3/ubuntu xenial main'
    

    2.3 安装MariaDB

    sudo apt update
    sudo apt install mariadb-server
    

    在安装中,你会被要求设置MariaDB的root密码。

    三、运行

    3.1 通过命令行连接MariaDB

    mysql -u root -p
    

    3.2 MariaDB 服务启动与停止

    sudo /etc/init.d/mysql stop
    sudo /etc/init.d/mysql start
    

    四、配置

    4.1 允许远程访问

    • 如果Ubuntu有设置防火墙或者iptables规则的话,请允许指定端口号访问
    • 判断3306端口是否打开

    4.1.1 使用 netstat命令查看3306端口状态

    netstat -an | grep 3306
    

    从上面结果可以看出3306端口只在IP 127.0.0.1 上监听,所以拒绝了其他IP的访问。

    解决方案:
    修改/etc/mysql/my.cnf文件。找到下面内容:

    #
    # Instead of skip-networking the default is now to listen only on
    # localhost which is more compatible and is not less secure.
    bind-address            = 127.0.0.1
    


    将上面这一行注释掉或者把127.0.0.1换成合适的IP,建议注释掉。
    重新启动后,重新使用netstat检测。

    使用命令测试

    mysql -h 192.168.0.xxx -u root -p
    Enter password:
    ERROR 1130 (HY000): Host '192.168.0.xxx' is not allowed to connect to this MariaDB server
    

    解决方案:需要将用户权限分配给各个远程用户
    登录mysql服务器,使用grant命令分配权限

    grant all on *.* to '用户名'@'%' identified by '密码';
    例子:grant all on *.* 'root'@'%' identified by '123456';
    


    这样即可远程访问了。

    五、管理工具

    建议使用官网自带的即可。
    https://downloads.mariadb.org/

  • 相关阅读:
    IOS苹果手机背景音乐不能自动播放问题
    手机自动刷视频方法
    elementUI form表单验证不通过的三个原因
    微信扫码登陆js
    地址转码方式
    css 过渡样式 transition
    vue项目打包踩坑记
    overflow
    怎么学习正则表达式?(正则的使用心得)
    微信小程序(template的使用)
  • 原文地址:https://www.cnblogs.com/jianxuanbing/p/8693157.html
Copyright © 2011-2022 走看看