MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。[4]
MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。在存储引擎方面,10.0.9版起使用XtraDB(名称代号为Aria)来代替MySQL的InnoDB。
rpm -qa|grep mariadb
rpm -qa | grep mysql
yum -y remove mysql
su - root
yum -y install mariadb mariadb-server
systemctl start mariadb
systemctl enable 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] –>是否重新加载权限表,回车
mysql -uroot -p
vim /etc/my.cnf
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
vim /etc/my.cnf.d/client.cnf
default-character-set=utf8
vi /etc/my.cnf.d/mysql-clients.cnf
default-character-set=utf8
systemctl restart mariadb
show variables like "%character%";show variables like "%collation%";
此时要想远程登录数据库,还需要先设置权限
create user username@localhost identified by 'password';
# 允许用户名为`username`的用户从任意ip以密码为password访问所有数据库
grant all privileges on *.* to username@'%' identified by 'password';
注意:
username@’%’ ,% 代表允许所有IP的username登录
username@localhost,localhost 代表允许本地username登录
[email protected],127.0.0.1 可以设置为单个IP,即允许单个远程主机登录
all privileges,代表所有权限
权限列表可被替换为一下任意组合:
select,insert,update,delete,create,drop,
index,alter,grant,references,reload,shutdown,process,file
use mysql
SELECT User, Host FROM user;
systemctl stop mariadb.service
mysqld_safe --skip-grant-tables &
mysql -u root
update mysql.user set password=PASSWORD('newpassword') where User='root’;
flush privileges;
systemctl start mariadb.service