美文网首页
Linux安装MariaDB(Mysql)和简单配置

Linux安装MariaDB(Mysql)和简单配置

作者: 开到荼蘼的弓 | 来源:发表于2017-12-18 10:11 被阅读39次

安装MariaDB

  1. 安装命令
    yum -y install mariadb mariadb-server
  2. 安装完成MariaDB,首先启动MariaDB
    systemctl start mariadb
  3. 设置开机启动
    systemctl enable mariadb
  4. MariaDB的相关简单配置
    mysql_secure_installation
  • 首先是设置密码,会提示先输入密码
Enter current password for root (enter for none):<–初次运行直接回车
  • 设置密码
Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码
  1. 其他配置
Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车

Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车,

Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车

Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车
  1. 初始化MariaDB完成,测试登录

mysql -uroot -ppassword

  1. 完成。

添加用户,设置权限

  1. 创建用户命令
    mysql>create user username@localhost identified by 'password';

  2. 直接创建用户并授权的命令
    mysql>grant all on *.* to username@localhost indentified by 'password';

  3. 授予外网登陆权限
    mysql>grant all privileges on *.* to username@'%' identified by 'password';

  4. 授予权限并且可以授权
    mysql>grant all privileges on *.* to username@'hostname' identified by 'password' with grant option;

  5. 刷新权限
    flush privileges;

相关文章

网友评论

      本文标题:Linux安装MariaDB(Mysql)和简单配置

      本文链接:https://www.haomeiwen.com/subject/lqppwxtx.html