踩坑前奏
连接MariarDB
没驱动
Driver class 'org.mariadb.jdbc.Driver' could not be found, make sure the 'MariaDB' driver (jar file) is installed.
org.mariadb.jdbc.Driver
复制代码
正式开始
查看数据库版本
## 下载连接 参考文章 没1个版本号一样的,随便选1个,应该没问题
Connection failed. Verify all connection parameters and confirm that the appropriate driver is installed.
Could not connect to HostAddress{host='192.168.1.18', port=3306, type='master'}. Host '10.0.0.2' is not allowed to connect to this MariaDB server
复制代码
改表法www.pianshen.com/article/196…还有授权法
Connection failed. Verify all connection parameters and confirm that the appropriate driver is installed.
Could not connect to HostAddress{host='192.168.*.*', port=3306, type='master'}. Host '10.0.*.*' is not allowed to connect to this MariaDB server
复制代码
重启数据库
禁用再启用一下,相当于重启
MariaDB创建远程用户访问,并设置只允许访问一个数据库.
-- 创建用户 create user 'user'@'%' identified by 'mm123456';
--示例1,允许所有从任意地址登录的用户: create user 'ActionNet'@'%' identified by 'zxc123';
--示例2,允许从192.168.199.100登录的用户: create user 'ActionNet'@'192.168.199.100' identified by 'zxc123'; grant all privileges on road.* to 'user'@'%';
-- 示例:授予任意地址登录ActionNet用户所有数据库所有权限 GRANT ALL ON *.* TO 'ActionNet'@'%';
flush privileges;
总算连上了
总结
java连数据库的jar包是对应数据库研发方提供的,所以应到对应数据库官网下载
来源 https://juejin.cn/post/7043427931414069285