win10环境搭建MariaDB数据库

  •   1、本次搭建mysql数据,选择了是和mysql类似的MariaDB,完全可以满足日常的使用需求,且命令和mysql没有太大的区别。

对应MariaDB下载地址:https://downloads.mariadb.org/

下载的文件:

 

  • 2、解压下载完成的文件,这里我解压到了D盘,路径:D:\mariadb-10.4.7-winx64

  • 3、使用win+R,输入CDM,进入DOS控制台。输入命令cd D:\mariadb-10.4.7-winx64 ,进入MariaDB的对应的路径中

如图所示:

  • 4、执行安装的命令:
mysqld.exe --install MariaDB 

注: 如果执行以上的安装命令出现错误,请使用管理员的身份打开cmd

  • 5、开启服务与关闭服务的命令:
net start MariaDB                #开启服务
net stop MariaDB                 #停止服务

此时容易出现一些错误,笔者这里就出现了1067的错误信息:

D:\mariadb-10.4.7-winx64\bin>net start MariaDB
mariadb 服务正在启动 ...
mariadb 服务无法启动。

系统出错。

发生系统错误 1067。

进程意外终止。

尝试了一些方法

进入到Mariadb的文件夹,data下面会有一个文件:主机名.err ,如下图

使用文本格式打开该文件,即可查看到对应的错误信息,类似:

……
InnoDB: using atomic writes. 2019-08-23 10:50:16 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions 2019-08-23 10:50:16 0 [Note] InnoDB: Uses event mutexes 2019-08-23 10:50:16 0 [Note] InnoDB: Compressed tables use zlib 1.2.11 2019-08-23 10:50:16 0 [Note] InnoDB: Number of pools: 1 2019-08-23 10:50:16 0 [Note] InnoDB: Using SSE2 crc32 instructions 2019-08-23 10:50:16 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2019-08-23 10:50:16 0 [Note] InnoDB: Completed initialization of buffer pool 2019-08-23 10:50:16 0 [Note] InnoDB: 128 out of 128 rollback segments are active. 2019-08-23 10:50:16 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2019-08-23 10:50:16 0 [Note] InnoDB: Setting file '.\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2019-08-23 10:50:16 0 [Note] InnoDB: File '.\ibtmp1' size is now 12 MB. 2019-08-23 10:50:16 0 [Note] InnoDB: Waiting for purge to start 2019-08-23 10:50:16 0 [Note] InnoDB: 10.4.7 started; log sequence number 113910; transaction id 9 2019-08-23 10:50:16 0 [Note] InnoDB: Loading buffer pool(s) from D:\mariadb-10.4.7-winx64\data\ib_buffer_pool 2019-08-23 10:50:16 0 [Note] Plugin 'FEEDBACK' is disabled. 2019-08-23 10:50:16 0 [ERROR] Could not open mysql.plugin table. Some plugins may be not loaded 2019-08-23 10:50:16 0 [Note] InnoDB: Buffer pool(s) load completed at 190823 10:50:16 2019-08-23 10:50:16 0 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist 2019-08-23 10:50:16 0 [Note] Server socket created on IP: '::'. 2019-08-23 10:50:16 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.db' doesn't exist 2019-08-23 10:50:16 0 [ERROR] Aborting

笔者这里解决的办法: 初始化mysql:mysql_install_db

D:\mariadb-10.4.7-winx64\bin>mysql_install_db
Default data directory is D:\mariadb-10.4.7-winx64\data
Running bootstrap
2019-08-23 10:51:36 0 [Note] D:\mariadb-10.4.7-winx64\bin\mysqld.exe (mysqld 10.4.7-MariaDB) starting as process 15452 ...
Removing default user
Creating my.ini file
Creation of the database was successful

执行以上的命令后,系统会在MariaDb安装文件下的data生成对应的文件。然后再次执行启动服务:

D:\mariadb-10.4.7-winx64\bin>net start MariaDB
mariadb 服务正在启动 .
mariadb 服务已经启动成功。

 

  • 6、在CMD窗口,对应MariaDB的bin目录中执行:mysql -u root -p,如下:输入密码时,直接Enter,直接进入MariaDM模式
D:\mariadb-10.4.7-winx64\bin>mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.4.7-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
  • 7、由于新的数据库是没有密码的,所以需要进行设置密码的操作命令:SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root');

如下:

MariaDB [(none)]> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root'););
Query OK, 0 rows affected (0.001 sec)

注:红色的字体代表,需要增加的密码。笔者这里设置数据库密码是root。

8、可以通过mysql shell的命名查MariaDB数据库的库名信息:

D:\mariadb-10.4.7-winx64\bin>mysql -u root -p
Enter password: ****
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.4.7-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, 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.001 sec)

 

posted @ 2019-08-23 13:01  RChow  阅读(6529)  评论(0编辑  收藏  举报