1 MariaDB介绍
MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。。
2 MariaDB 下载
下载地址:
https://downloads.mariadb.org/mariadb/10.2.12/
压缩后的文件夹放在C盘根目录下即可。也可以放在其他目录下。
解压到一个目,假设解压到D:/mariadb/mariadb-10.2.12-winx64目录
3 修改配置文件
打开解压目录,然后找到my-large,my-medium,my-small,三个文件,根据你的电脑的 配置进行选择,我这里选择的是my-large文件,将my-large复制到C盘的C:/Windows/目录下, 将名字修改为my.ini。
增加并修改以下内容:
[client]
/#password = your_password
port = 3306
socket = /tmp/mysql.sock
default-character-set=utf8
[mysqld]
port = 3306
socket = /tmp/mysql.sock
default-storage-engine=INNODB
character_set_server=utf8
basedir=D:/mariadb/mariadb-10.2.12-winx64
datadir=D: /mariadb/data
[mysql]
no-auto-rehash
default-character-set=utf8
[WinMySQLAdmin]
Server= D:/mariadb/mariadb-10.2.12-winx64/bin/mysqld.exe
4 创建数据库实例
https://mariadb.com/kb/zh-cn/installing-mariadb-windows-zip-packages/
https://mariadb.com/kb/en/library/mysql_install_dbexe/
C:/Windows/system32>d:
D:/>cd D:/mariadb/mariadb-10.2.12-winx64/bin
D:/mariadb/mariadb-10.2.12-winx64/bin>mysql_install_db.exe --datadir=D:/mariadb/data
会在D: //mariadb/data 目录下生成实例及系统表
5 命令行启动数据库
C:/Windows/system32>d:
D:/>cd D:/mariadb/mariadb-10.2.12-winx64/bin
D:/mariadb/mariadb-10.2.12-winx64/bin>mysqld –console
D:/mariadb/mariadb-10.2.12-winx64/bin>mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or /g.
Your MariaDB connection id is 8
Server version: 10.2.12-MariaDB mariadb.org binary distribution
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
6 关闭mariadb 服务
D:/mariadb/mariadb-10.2.12-winx64/bin>mysqladmin -uroot shutdown
7 将 MariaDB 安装为 Windows 服务
在开始菜单输入cmd,右击以管理员身份运行,运行后将执行目录cd到mariadb解压bin目录中
C:/Windows/system32>d:
D:/>cd D:/mariadb/mariadb-10.2.12-winx64/bin
安装服务
D:/mariadb/mariadb-10.2.12-winx64/bin>mysqld --install MariaDB
Service successfully installed.
安装成功之后既可以在运行里输入services.msc 启动关闭MariaDB 服务
也可以命令行方式启动关闭MariaDB 服务
D:/mariadb/mariadb-10.2.12-winx64/bin> net start MariaDB
MariaDB 服务正在启动 .
MariaDB 服务已经启动成功。
D:/mariadb/mariadb-10.2.12-winx64/bin>net stop MariaDB
MariaDB 服务正在停止.
MariaDB 服务已成功停止。
8 修改root密码
D:/mariadb/mariadb-10.2.12-winx64/bin>mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or /g.
Your MariaDB connection id is 8
Server version: 10.2.12-MariaDB mariadb.org binary distribution
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
MariaDB [(none)]> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');
Query OK, 0 rows affected (0.00 sec)
或者:
D:/mariadb/mariadb-10.2.12-winx64/bin>mysqladmin -u root password "新密码"
9 删除服务
C:/Windows/system32>d:
D:/>cd D:/mariadb/mariadb-10.2.12-winx64/bin>mysqld --remove MariaDB
10 配置环境变量
右键电脑-属性-高级系统设置-高级-环境变量 在Path 变量中加入MariaDB bin目录:
D:/mariadb/mariadb-10.2.12-winx64/bin
cmd 输入mysql -uroo -p 即可登录MariaDB 数据库
C:/Windows/system32>mysql -uroot -p
Enter password: ****
Welcome to the MariaDB monitor. Commands end with ; or /g.
Your MariaDB connection id is 17
Server version: 10.2.12-MariaDB-log mariadb.org binary distribution
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
个人博客地址:
http://www.cndba.cn/leo1990