数字化办公-非可信数据库部署
非可信数据库部署
- 下载最新版本MySQL Community Server数据库zip文件,以8.0.26版本举例:
- 新建E:\mysql-8.0.26-winx64\my.ini文件,文件内容如下:
[client]# 不推荐使用默认端口3306port=3308default-character-set=utf8mb4[mysql]default-character-set=utf8mb4[mysqld]# 不推荐使用默认端口3306port=3308# 绝对路径依据实际情况修改basedir="E:/mysql-8.0.26-winx64/"datadir="E:/mysql-8.0.26-winx64/data/"# tmpdir="E:/mysql-8.0.26-winx64/data/temp/"# General and Slow logging.log-output=FILEgeneral-log=0general_log_file="seeyon-mysql-8.0-general.log"slow-query-log=1slow_query_log_file="seeyon-mysql-8.0-slow.log"long_query_time=10# Error Logging.log-error="seeyon-mysql-8.0.err"# default_authentication_plugin=caching_sha2_passworddefault_authentication_plugin=mysql_native_passworddefault-storage-engine=INNODBcharacter-set-server=utf8mb4max_connections=600max_connect_errors=100transaction_isolation=READ-COMMITTEDmax_allowed_packet=64Mdefault-time-zone='+8:00'log_timestamps=systemlower_case_table_names=1table_open_cache=2000tmp_table_size=512Mkey_buffer_size=512Minnodb_flush_log_at_trx_commit=1innodb_log_buffer_size=16Minnodb_buffer_pool_size=4Ginnodb_log_file_size=1Ginnodb_autoextend_increment=64innodb_buffer_pool_instances=8innodb_open_files=300innodb_file_per_table=1
如果使用记事本编辑保存,请另存为,设置编码ANSI。
图1 另存为 - 开始菜单,找到命令提示符,以管理员身份运行,执行命令cd /d E:\mysql-8.0.26-winx64\bin切换路径
图2 切换路径
初始化数据库,执行命令mysqld --initialize --console,记住生成的随机密码
图3 初始化数据库注册Windows服务,执行命令
mysqld.exe --install MySQL8.0 --defaults-file="E:\mysql-8.0.26-winx64\my.ini"
成功则提示Service successfully installed.
图4 注册Windows服务 - 创建E:\mysql-8.0.26-winx64\data\temp目录,修改my.ini文件解除注释(去掉行首的#)
tmpdir="E:/mysql-8.0.26-winx64/data/temp/"
图5 创建目录 - 启动MySQL8.0服务
图6 启动MySQL8.0服务
- 使用mysql命令行登录数据库修改root密码(需要初始化数据库生成的随机密码,以下举例供参考,以实际密码为准)
cd /d E:\mysql-8.0.26-winx64\binmysql -uroot -P3308 -p3gNvcqvXvC/p
图7 修改密码root新密码设置为newpwd654321
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpwd654321';flush privileges;
图8 图示1创建seeyon账号设置密码为oapwd654321,允许协同服务器10.3.4.239远程访问数据库
create user 'seeyon'@'10.3.4.239' identified by 'oapwd654321';flush privileges;grant all privileges on *.* to 'seeyon'@'10.3.4.239';flush privileges;
如果允许所有服务器通过seeyon账号远程访问数据库,则执行
create user 'seeyon'@'%' identified by 'oapwd654321';flush privileges;grant all privileges on *.* to 'seeyon'@'%';flush privileges;
图9 图示2 - 创建V8X数据库命令示例:CREATE DATABASE V8X DEFAULT CHARACTER SET UTF8MB4;
图10 命令示例
- 操作系统防火墙中添加数据库端口(本例中是3308)允许访问策略。