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

安装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;

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。