1.首先讲一下MariaDB与Mysql的关系。
MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。
2.安装MariaDB
安装命令
yum -y install mariadb mariadb-server
安装完成后,启动MariaDB
systemctl start mariadb
下面就是配置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: <– 再输入一次你设置的密码
其他配置
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] <– 是否重新加载权限表,回车
初始化MariaDB完成,接下来测试登录
mysql -uroot -ppassword
3.配置字符集
在文件/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
文件/etc/my.cnf.d/client.cnf下
vi /etc/my.cnf.d/client.cnf
在[client]中添加
default-character-set=utf8
vi /etc/my.cnf.d/mysql-clients.cnf
在[mysql]中添加
default-character-set=utf8
systemctl restart mariadb
创建用户
MariaDB>create user username@localhost identified by 'password';
直接创建用户并授权的命令
MariaDB>grant all on *.* to username@localhost indentified by 'password';
授予外网登陆权限
MariaDB>grant all privileges on *.* to username@'%' identified by 'password';
授予权限并且可以授权
MariaDB>grant all privileges on *.* to username@'hostname' identified by 'password' with grant option;
5.最后就是刷新权限了
flush privileges;
用navicat管理软件就可以远程连接了。