ubuntu server 安装 mariadb

来源:互联网 发布:淘宝网手工布鞋 编辑:程序博客网 时间:2024/06/04 18:23

设置 MariaDB 仓库

默认MariaDB的包并没有在Ubuntu仓库中。要安装MariaDB,我们首先要设置MariaDB仓库。(ubuntu server 版跳过这一步)
1. sudoaptgetinstallsoftwarepropertiescommon2. sudo apt-key adv –recv-keys –keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
3. $ sudo add-apt-repository ‘deb http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu trusty main’

安装 MariaDB

  1. $ sudo apt-get update
  2. $ sudo apt-get install mariadb-server

从命令行连接到MariaDB

  1. fengdu@localhost:~$ mysql -u root -p
  2. Enter password:

从命令行连接到MariaDB

  1. 如果Ubuntu有设置防火墙或者iptables规则的话,请自行打开
  2. 3306端口是不是没有打开?
    使用nestat命令查看3306端口状态:
    ~# netstat -an | grep 3306
    tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
    从结果可以看出3306端口只是在IP 127.0.0.1上监听,所以拒绝了其他IP的访问。
    解决方法:
    nano /etc/mysql/my.cnf 打开文件,添加 bind-address = * 到文件中
    运行 service mysql stop
    运行 service mysql start

分配用户权限

  1. 登录到mariadb服务器,使用grant命令分配权限
    mariadb> grant all on . to ‘root’@’%’ identified by ‘你的密码’;
    root 是你的用户名
    % 代表所有的远程ip

0 0