主节点安装 MySql

  • 安装 mysql 服务器命令如下:

    yum install mysql-server
    
  • 设置开机启动命令如下:

      chkconfig mysqld on
    
  • 启动 mysql 服务命令如下:

      service mysqld start
      #根据提示设置 root 的初试密码命令:
      mysqladmin -u root password 123456
    
  • 进入 mysql 命令行命令如下:

      mysql -uroot –p
      #输入密码  
      123456
    

    image-20210507222653878

  • 在 Mysql 中执行这四步:

      create database hive DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
      create database amon DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
      grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
      flush privileges;
    
备注说明:
创建以下数据库:

```mysql
#hive
create database hive DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
#activity monitor
create database amon DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
#设置 root 授权访问以上所有的数据库:
#授权 root 用户在主节点拥有所有数据库的访问权限
grant all privileges on *.* to 'root'@'n1' identified by 'xxxx' with grant option;flush privileges;
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;flush privileges;
#对用户授权
mysql>grant rights on database.* to user@host identified by "pass";
#例 1:
#增加一个用户 test1 密码为 abc,让他可以在任何主机上登录,并对所有数据库有查询、插
#入、修改、删除的权限。
grantselect,insert,update,delete on *.* to test1@"%" Identified by "abc";
ON 子句中*.* 说明符的意思是“所有数据库,所有的表”
#例 2:
#增加一个用户 test2 密码为 abc, 让他只可以在 localhost 上登录,并可以对数据库 mydb 进行
#查询、插入、修改、删除的操作。
grant select,insert,update,delete on mydb.* to test2@localhost identified by "abc";
```



下节 [主节点安装 hive 和启动](7.md)

results matching ""

    No results matching ""