未名Q

此生若能得幸福安稳,谁又愿颠沛流离。

  :: 首页 :: 博问 :: 闪存 :: 新随笔 :: :: 订阅 订阅 :: 管理 ::

MySQL 5.7/8.0 zip

先安装

rem 配置系统环境变量 Path  中添加 mysql.zip\bin
cd /d mysql.zip\bin
rem 本地root密码为空
mysqld --initialize-insecure
mysqld install
net start mysql

查找my.ini/my.cnf文件放法:

MySQL :: MySQL 5.7 Reference Manual :: 4.2.2.2 Using Option Files

Configuring MariaDB with Option Files - MariaDB Knowledge Base 有的安装方式下是没有my.ini/my.cnf文件的,比如这个ZIP

data/my.ini

[mysqld]
datadir=C:/Program Files/MariaDB 10.3/data
port=33060
innodb_buffer_pool_size=243M
character-set-server=utf8
[client]
port=33060
plugin-dir=C:/Program Files/MariaDB 10.3/lib/plugin

 

再本地登录

mysql -u root -p
mysql –u root –ppassword
mysql –h localhost -P 3306 -uroot –ppassword

创建远程可登录root账号与授权(这一步可跳过)

CREATE USER 'root'@'%' IDENTIFIED BY 'root123';
flush privileges;
select host,user from mysql.user where user='root';
GRANT all privileges ON *.* TO 'root'@'%';

show grants for 'root'@'%';
revoke all PRIVILEGES ON `axshar`.* from `axuser`@`%`;

set password for 'user'@'host' = password('新密码');

后创建数据库与用户

-- 1.创建数据库
CREATE DATABASE IF NOT EXISTS study DEFAULT CHARSET utf8;

-- 2.创建用户并授权
CREATE USER 'ustudy'@'%' IDENTIFIED BY 'ustudy';
flush privileges;
select host,user from mysql.user;
GRANT all privileges ON study.* TO 'ustudy'@'%';

MySQL 8.0 Public Key Retrieval is not allowed 错误的解决方法
解决方法是在连接后面添加 allowPublicKeyRetrieval=true


mysqld.exe是MySQL的主程序,mysqld意思是mysql daemon(后台进程),在后台运行,监听3306端口。
mysql.exe是MySQL的命令行工具,是一个客户端软件,可以对任何主机的mysql服务(即后台运行的mysqld)发起连接。
mysqladmin.exe是一个执行管理操作的客户端,例如创建或删除数据库,重新加载授权表,将表刷新到磁盘以及重新打开日志文件。
root账号第一次登录是没有密码,也可继续修改密码:mysqladmin -u root -p password

mysqlshow.exe是用来查看当前数据库、表、索引、视图等
mysqldump.exe是mysql 数据导出及备份工具。
mysqlslap.exe是mysql 性能分析测试工具。

 

-- 查看 datadir 位置 、数据库、数据库字符集
show variables like 'datadir';
Show databases;
select schema_name,default_character_set_name from information_schema.schemata where schema_name = 'study';

-- 撤销用户权限:由grant变REVOKE
REVOKE privilege ON databasename.tablename FROM 'username'@'host';

-- 删除用户
DROP USER 'username'@'host';

Access denied; you need (at least one of) the SUPER privilege(s) for this operation

原因是需要超级权限,而当前登录账号没有这个权限。

一是在服务器上使用Navicat for MySQL登录数据库并且IP地址用localhost;
二是把DEFINER=`root`@`localhost`的localhost改为你的服务器IP;
三是在你的sql文件中删除DEFINER=`root`@`localhost`这个限制。

update mysql.user set super_priv='Y' where user='axuser';
flush privileges

MySQL 5.6

配置系统环境变量 Path 中添加 mysql.zip\bin

复制 mysql.zip\my-default.ini 为 my.ini ,并打开。

basedir = mysql.zip
datadir = mysql.zip\data
port = 3306

安装MySQL数据库

cd /d mysql.zip\bin

mysqld -install 回车,安装mysql服务成功;

mysqld -remove 是卸载mysql。

net start mysql 服务启动;

net stop mysql 是停止服务。

root账号第一次登录是没有密码,也可继续修改密码:mysqladmin -u root -p password

MariaDB与MySQL版本主要特性兼容对照

MariaDB versus MySQL - Compatibility - MariaDB Knowledge Base

MariaDB 10.2, MariaDB 10.3, and MariaDB 10.4 function as limited drop-in replacements for MySQL 5.7, as far as InnoDB is concerned. However, the implementation differences continue to grow in each new MariaDB version.

连接安全

MySQL的Connection-Control介绍 - 潇湘隐者 - 博客园 (cnblogs.com)

MySQL参数max_connect_errors分析释疑 - 潇湘隐者 - 博客园 (cnblogs.com)

MySQL安全插件:Connection-Control Plugins 的利与弊_leonpenn的博客-CSDN博客

 

MariaDB没有connection_control插件,但支持 @@max_password_errors 变量。

dbeaver ce

/* https://github.com/dbeaver/dbeaver/releases/download/6.3.5/dbeaver-ce-6.3.5-x86_64-setup.exe

 

https://dbeaver.io/files/dbeaver-ce-latest-x86_64-setup.exe
Oracle 不需要安装 instantclient_11_2,自动从maven下载jdbc。

1、使用阿里云方法:窗口--首选项--连接--驱动--Maven
下载驱动文件>下载配置>驱动>maven中添加,并移动最上面。
https://maven.aliyun.com/repository/public/
2、关闭SQL补全表别名:窗口--首选项--Editors--SQL补全--insert table aliases (in FROM clause)
3、标题字段名显示备注:窗口--首选项--Editors--结果集--表示--在标题栏中显示列描述
4、单次记录条数:窗口--首选项--Editors--结果集--集数获取大小
5、关闭启动检查更新:窗口--首选项--User Interface--自动检查更新
6、SQL编辑器里自动换行显示:右键--格式--自动换行
7、关闭SQL脚本错误输出窗口:窗口--首选项--Editors--SQL编辑器--在新消息上打开输出查看器

单个“数据库连接”配置:
10、数据库连接--编辑连接--连接设置--初始台:是否自动提交、隔离级别、默认库/模式
11、数据库连接--编辑连接--常规:连接类型(dev/test/prod)、安全性、过滤
12、数据库连接--Connection view--Advanced:简单与自定义很只显示表,其他对像(存储过程==)都不显示。

SQL编辑器中,F4可以查看表。
*/

posted on 2022-11-27 13:06  未名Q  阅读(69)  评论(1编辑  收藏  举报