Ubuntu安装MariaDB教程

1、环境

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

2、安装流程

2.1 进入MariaDB 网站

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

mysql

2.2 设置MariaDB 仓库

默认上MariaDB的包并无在Ubuntu仓库中。要安装MariaDB,咱们要设置MariaDB仓库。sql

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、运行

3.1 经过命令行链接MariaDB

mysql -u root -p

3.2 MariaDB 服务启动与中止

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

4、配置

4.1 容许远程访问

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

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

netstat -an | grep 3306

从上面结果能够看出3306端口只在IP 127.0.0.1 上监听,因此拒绝了其余IP的访问。ubuntu

解决方案:
修改/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检测。
less

使用命令测试ide

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';


这样便可远程访问了。测试

5、管理工具

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

相关文章
相关标签/搜索