Windows 免安装运行MariaDB 11.4

下载

https://mariadb.org/download/?t=mariadb&o=true&p=mariadb&r=11.4.4&os=windows&cpu=x86_64&pkg=zip&mirror=xtom_hk

解压

解压到指定位置(建议放在SSD所在盘符),如:

D:\mariadb-11.4.4

Linux安装教程:

https://mariadb.com/kb/en/installing-mariadb-binary-tarballs/

设置用户环境变量

添加新的用户环境变量:MARIADB_HOME

C:\green\mariadb-11.4.4

添加PATH:

%MARIADB_HOME%\bin

初始化

命令窗口,跳转到 mariadb-11.4.4\bin\,执行:

mariadb-install-db.exe --datadir=../data --password=your_password

查看执行结果:

Running bootstrap
Creating my.ini file
Removing default user
Setting root password
Creation of the database was successful

如上,表示初始化成功。
注:mariadb-install-db.exe详细参数说明见

https://mariadb.com/kb/en/mariadb-install-db-exe/

启动

mariadbd.exe --basedir=../ --datadir=../data/ --console

保持窗口打开状态

连接

使用客户端工具连接MariaDB,然后执行:

select version();

结果显示:11.4.4-MariaDB,表明安装并启动成功。

停止

ctrl + C,关闭命令窗口。

Linux下的免安装运行:

解压到:

/app_home/mariadb-11.4.4

在此目录下创建data目录用于存放数据库文件。
再初始化:

./scripts/mariadb-install-db --basedir=./ --datadir=./data/

执行结果:

Installing MariaDB/MySQL system tables in './data/' ...
OK

To start mariadbd at boot time you have to copy
support-files/mariadb.service to the right place for your system


Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is chkusr@localhost, it has no password either, but
you need to be the system 'chkusr' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo

See the MariaDB Knowledgebase at https://mariadb.com/kb

You can start the MariaDB daemon with:
cd './' ; .//bin/mariadbd-safe --datadir='./data/'

You can test the MariaDB daemon with mariadb-test-run.pl
cd './/mariadb-test' ; perl mariadb-test-run.pl

Please report any problems at https://mariadb.org/jira

The latest information about MariaDB is available at https://mariadb.org/.

Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

配置自定义端口文件

./mariadb-11.4.4/my.cnf

[mysqld]
port=3307

优化参数配置,可往my.cnf追加配置:

innodb_buffer_pool_size=2147483648
innodb_flush_log_at_trx_commit=2
sync_binlog=0
sort_buffer_size=4194304
join_buffer_size=4194304
read_buffer_size=4194304

Linux下启动

nohup ./bin/mariadbd-safe --defaults-file=./data/my.cnf &

客户端登录

初始化和启动后,默认用户有两个,一个是root,一个是当前linux登录用户,通过客户端方式:

./bin/mariadb -u your_user

登录进去,然后设置密码和允许远程访问:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root';
GRANT ALL PRIVILEGES ON *.* TO 'your_user'@'%' IDENTIFIED BY 'your_user';

改密码:

ALTER USER 'root'@'%' IDENTIFIED BY 'your_password';
ALTER USER 'your_user'@'%' IDENTIFIED BY 'your_password';

刷新:

flush privileges;

退出maria客户端命令行:

exit

重新登录验证密码

./bin/mariadb -uroot -p

输入上面的密码,再登录。

停止服务

./bin/mariadb-admin -uroot -p'Xinshare123@' shutdown -S
posted @ 2024-11-12 11:15  漠孤烟  阅读(7)  评论(0编辑  收藏  举报