美文网首页
MARIADB 安装

MARIADB 安装

作者: 白云青叶 | 来源:发表于2020-07-20 19:11 被阅读0次

    1、文档说明
    安装MARIADB
    2 安装步骤
    2.1 安装MARIADB
    yum -y install mariadb mariadb-server
    2.2 启动MARIADB
    systemctl start mariadb
    2.3 设置开机启动
    systemctl enable mariadb
    3 简单配置
    mysql_secure_installation
    3.1 设置密码
    Enter current password for root (enter for none):<–初次运行直接回车
    Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
    New password: <– 设置root用户的密码
    Re-enter new password: <– 再输入一次你设置的密码
    3.2 其它配置
    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] <– 是否重新加载权限表,回车
    3.3 测试登录
    mysql -uroot -ppassword
    本次测试的用户名为root ,密码为 *******
    4 配置字符集
    4.1 /ETC/MY.CNF
    vi /etc/my.cnf
    在[mysqld]标签下添加
    init_connect='SET collation_connection = utf8_unicode_ci'
    init_connect='SET NAMES utf8'
    character-set-server=utf8
    collation-server=utf8_unicode_ci
    skip-character-set-client-handshake
    4.2 /ETC/MY.CNF.D/CLIENT.CNF
    在[client]中添加
    default-character-set=utf8
    4.3 文件/ETC/MY.CNF.D/MYSQL-CLIENTS.CNF
    vi /etc/my.cnf.d/mysql-clients.cnf
    在[mysql]中添加
    default-character-set=utf8
    4.4 重启MARIADB
    systemctl restart mariadb
    4.5 查看字符集
    mysql -uroot -p*******
    show variables like "%character%";show variables like "%collation%";
    显示:
    +--------------------------+----------------------------+
    | Variable_name | Value |
    +--------------------------+----------------------------+
    | character_set_client | utf8 |
    | character_set_connection | utf8 |
    | character_set_database | utf8 |
    | character_set_filesystem | binary |
    | character_set_results | utf8 |
    | character_set_server | utf8 |
    | character_set_system | utf8 |
    | character_sets_dir | /usr/share/mysql/charsets/ |
    +--------------------------+----------------------------+
    8 rows in set (0.00 sec)
    +----------------------+-----------------+
    | Variable_name | Value |
    +----------------------+-----------------+
    | collation_connection | utf8_unicode_ci |
    | collation_database | utf8_unicode_ci |
    | collation_server | utf8_unicode_ci |
    +----------------------+-----------------+
    3 rows in set (0.00 sec)
    出现以上,则字符集配置完成
    5 设置权限
    5.1 创建用户命令
    create user demo@localhost identified by '******';
    5.2 直接创建用户并授权的命令
    grant all on . to demo@localhost identified by '******';;
    5.3 授予外网登录权限
    grant all privileges on . to demo@'%' identified by '******';;
    5.4 授予权限并且可以授权
    grant all privileges on . to demo@'%' identified by '******'; with grant option;
    5.5 刷新权限
    flush privileges;
    5.6 限制用户使用指定数据库
    use mysql
    CREATE USER 'study'@'localhost' IDENTIFIED BY 'asb#1234';
    GRANT SELECT, INSERT, UPDATE, REFERENCES, DELETE, CREATE, DROP, ALTER, INDEX, CREATE VIEW, SHOW VIEW ON study.* TO 'study'@'localhost' identified by '******';;
    GRANT SELECT, INSERT, UPDATE, REFERENCES, DELETE, CREATE, DROP, ALTER, INDEX, CREATE VIEW, SHOW VIEW ON study.* TO 'study'@'%' identified by '******';;
    flush privileges;
    6 表名大小写忽略
    6.1 文件/ETC/MY.CNF
    [mysqld]
    lower_case_table_names=1
    6.2 重启数据库
    systemctl restart mariadb

    7 参考地址
    7.1 安装MARIADB
    https://www.cnblogs.com/jpfss/p/6568976.html
    7.2 指定用户访问指定数据库
    https://blog.csdn.net/u014796999/article/details/52952253
    7.3 表名忽略大小写问题
    https://blog.csdn.net/u011365831/article/details/79301182

    相关文章

      网友评论

          本文标题:MARIADB 安装

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