系统相关
首页 > 系统相关> > Centos7安装mariaDB

Centos7安装mariaDB

作者:互联网

Installing MariaDB Server 10.4

To deploy MariaDB Community Server 10.4 on RHEL 7 or CentOS 7, first download and use the mariadb_repo_setup script to configure the MariaDB repositories for YUM:

$ sudo yum install wget
$ wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
$ chmod +x mariadb_repo_setup
$ sudo ./mariadb_repo_setup

To install MariaDB Community Server and dependencies:

$ sudo yum install MariaDB-server -y

Configuring and Securing MariaDB Server

Start the systemd service for MariaDB Server 5.5 or 10.4 using systemctl:

$ sudo systemctl start mariadb.service

Specific security practices should always follow any business-specific requirements and governance. Some basic steps should be taken to help harden the MariaDB Community Server 5.5 or 10.4 deployment:

$ sudo mariadb-secure-installation

1.输入当前密码,初次安装后是没有密码的,直接回车 2.询问是否使用 'unix_socket' 进行身份验证: n 3.为 root 设置密码:y 4.输入 root 的新密码: root 5.确认输入 root 的新密码: root 6.是否移除匿名用户,这个随意,建议删除: y 7.拒绝用户远程登录,这个建议开启:n 8.删除 test 库,可以保留:n 9.重新加载权限表:y     设置mysql的中文编码支持,修改/etc/my.cnf 1.vim /etc/my.cnf 在[mysqld]中添加参数,使得mariadb服务端支持中文 [mysqld] character-set-server=utf8 collation-server=utf8_general_ci    2.重启mariadb服务,读取my.cnf新配置 systemctl restart mariadb      

MySQL创建用户与授权

 

一. 创建用户

命令:CREATE USER 'username'@'host' IDENTIFIED BY 'password';

说明:
username:你将创建的用户名
host:指定该用户在哪个主机上可以登陆,如果是本地用户可用localhost,如果想让该用户可以从任意远程主机登陆,可以使用通配符%
password:该用户的登陆密码,密码可以为空,如果为空则该用户可以不需要密码登陆服务器
例子:
CREATE USER 'dog'@'localhost' IDENTIFIED BY '123456';
CREATE USER 'pig'@'192.168.1.101_' IDENDIFIED BY '123456';
CREATE USER 'pig'@'%' IDENTIFIED BY '123456';
CREATE USER 'pig'@'%' IDENTIFIED BY '';
CREATE USER 'pig'@'%';


二. 授权:

命令:GRANT privileges ON databasename.tablename TO 'username'@'host'

说明:
privileges:用户的操作权限,如SELECT,INSERT,UPDATE等,如果要授予所的权限则使用ALL
databasename:数据库名
tablename:表名,如果要授予该用户对所有数据库和表的相应操作权限则可用*表示,如*.*
例子:
GRANT SELECT, INSERT ON test.user TO 'pig'@'%';
GRANT ALL ON *.* TO 'pig'@'%';
GRANT ALL ON maindataplus.* TO 'pig'@'%';
注意:
用以上命令授权的用户不能给其它用户授权,如果想让该用户可以授权,用以下命令:
GRANT privileges ON databasename.tablename TO 'username'@'host' WITH GRANT OPTION;

 

标签:MariaDB,GRANT,用户,pig,Centos7,USER,mariaDB,安装,mariadb
来源: https://www.cnblogs.com/xtxtx/p/16325513.html