MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。在存储引擎方面,使用XtraDB(英语:XtraDB)来代替MySQL的InnoDB。
官方网址:https://mariadb.org
配置文件模板在根目录下,如mariadb-10.0.5-winx64\my-small.ini。除此之外还有my-medium.ini、my-large.ini、my-huge.ini和my-innodb-heavy-4G.ini.
请你根据自己机器的内存大小和实际需要,新建一个my.ini配置文件在此目录下。
为了支持表的行锁,我们需要使用InnoDB,以my-small.ini为例,我们需要打开(所指定的目录必须存在):(如果配置出错,比如没有对应的文件夹,服务启动不了)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# Uncomment the following if you are using InnoDB tables
innodb_data_home
_dir
=
E
:
\
\
dbserver
\
\
mariadb
\
\
mariadb
-
10.0.5
-
winx64
\
\
data
\
\
#data配置在mariadb下data目录,配置在其他地方,如果创建的是innodb,第二次启动就有问题了
innodb_data_file
_path
=
ibdata1
:
10M
:
autoextend
innodb_log_group_home
_dir
=
E
:
\
\
dbserver
\
\
mariadb
\
\
log
\
\
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool
_size
=
16M
innodb_additional_mem_pool
_size
=
2M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file
_size
=
5M
innodb_log_buffer
_size
=
8M
innodb_flush_log_at_trx
_commit
=
1
innodb_lock_wait
_timeout
=
50
innodb_force
_recovery
=
1
#强制启动mysql,当innodb表空间损坏时候,启动不了,可以强制启动;没有这行有时候会报InnoDB: Warning: Using innodb_additional_mem_pool_size is DEPRECATED. This option may be removed in future releases, together with the option innodb_use_sys_malloc and with the InnoDB's internal memory allocator
|
为了保留我们操作数据库的操作记录,需要打开二进制记录:
1
2
|
# Uncomment the following if you want to log updates
log
-
bin
=
mysql
-
bin
|
1
|
[
client
]
default
-
character
-
set
=
utf8
|
通过cmd命令行在(mariadb-10.0.5-winx64\bin目录下执行):注意:请使用管理员权限安装
1
2
|
mysqld
.
exe
--
install
MariaDB
mysqld
.
exe
--
remove
MariaDB
|
通过cmd命令行在(mariadb-10.0.5-winx64\bin目录下执行):
1
2
|
net
start
MariaDB
net
stop
MariaDB
|
设置root密码
通过cmd命令行(mariadb-10.0.5-winx64\bin目录下执行):
1
|
mysqladmin
-
u
root
password
"123456"
|
自此MariaDB数据库就创建完毕,可以用客户端工具连接上来,如navicat for mysql
其他。MariaDB数据的命令和MySQL几乎一模一样,MySQL5.5之前的解决方案,完全可以用Maria替代MySQL.
1
|
mysqladmin
-
u
root
-
p
[
oldpass
]
password
newpass
|
注意oldpass(老密码)可选,如果root默认密码为空,则不需要输入
如果需要更改老密码,请注意老密码与-p之间不要有空格,否则会报错,另外password和newpass(新密码)之间以空格分隔。
关掉mysqldaemon程序或服务
1
2
3
4
|
safe
_mysqld
--
skip
-
grant
-
tables
&
use
mysql
update
user
set
password
=
password
(
"new_pass"
)
where
user
=
"root"
;
flush
privileges
;
|
1
|
netsh
firewall
add
portopening
TCP
3306
MySQL
(
3306
)
|
1
2
3
4
5
|
mysql
-
u
root
-
p123456
mysql
>
use
mysql
;
mysql
>
update
user
set
host
=
'%'
where
user
=
'root'
;
mysql
>
flush
privileges
;
mysql
>
select
'host'
from
user
where
user
=
'root'
;
|
CREATE USER '用户名'@'localhost或者%' IDENTIFIED BY '密码';
1
2
3
|
grant
select
,
insert
,
update
,
delete
on
mydb
.
*
to
'用户名'
@
'localhost或者%'
identified
by
'密码'
;
flush
privileges
;
select
*
from
mysql
.
user
|
1
|
drop
user
'用户名'
@
'localhost或者%'
;
|