Centos 7 yum 安装mariadb

1、mariadb安装

[root@localhost ~]# yum -y install mariadb mariadb-server

#安装完成后启动mariadb并添加到自启动
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# systemctl enable mariadb


#mariadb设置:root密码等
[root@localhost ~]# mysql_secure_installation
1、设置密码,首次进入无密码,直接回车
Enter current password for root (enter for none): 回车
OK, successfully used password, moving on...

2、设置root密码
Set root password? [Y/n] y
New password: 输入root密码
Re-enter new password: 输入root密码
Password updated successfully!
Reloading privilege tables..
 ... Success!

3、是否删除匿名用户
Remove anonymous users? [Y/n] 回车
 ... Success!
4、是否禁止root远程登录
Disallow root login remotely? [Y/n]
 ... Success!
5、是否删除test数据库
Remove test database and access to it? [Y/n]
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
6、是否重新加载权限表
Reload privilege tables now? [Y/n]
 ... Success!

Cleaning up...

mariadb安装完成,使用mysql -uroot -p登录测试

 

2、mariadbz字符集配置

修改/etx/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

修改/etc/my.cnf.d/client.cnf,在[client]中添加

default-character-set=utf8

修改/etc/my.cnf.d/mysql-clients.cnf,在[mysql]中添加

default-character-set=utf8

重启mariadb

[root@localhost ~]# systemctl restart mariadb

进入mariadb查看字符集

MariaDB [(none)]> show variables like "%character%";show variables like "%collat              ion%";
+--------------------------+----------------------------+
| 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.01 sec)

3、用户、权限设置

配置root允许远程访问

MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'root' WITH GRANT OPTION;
Query OK, 0 rows affected (0.03 sec)

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

创建用户命令

create user username@localhost identified by 'password';


直接创建用户并授权的命令

grant all privileges on *.* to test@'%' identified by 'test';


授予外网登陆权限 

grant all privileges on *.* to username@'%' identified by 'password';


授予权限并且可以授权

grant all privileges on *.* to username@'192.168.100.200' identified by 'password' with grant option;

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Rzhidong

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值