当前位置:网站首页>Linux下安装Mysql 8.0 + eclipse配置详细教程
Linux下安装Mysql 8.0 + eclipse配置详细教程
2022-04-22 19:53:00 【我爱让机器学习】
目录
安装MySql:
我用的是Ubuntu20.04,所以直接使用以下命令进行安装:
sudo apt-get install mysql-server
若其他可以先更新源:
sudo apt-get update
查看是否安装成功:
systemctl status mysql

启动mysql:
sudo mysql //不用输入密码,也可以su进入超级用户直接使用mysql
//或者
mysql -u root -p //需要输入密码

mysql会自动生成一个密码,查看方法:
sudo cat /etc/mysql/debian.cnf

至此Mysql安装成功,初始密码也得到了。
eclipse配置mysql:
去MySQL官网下载Java的JDBC。
操作如图:






将下载后的文件解压。

打开eclipse => Window => Preferences
我已经创建了JDBC一个所以他报错。

再重新回到刚才的界面:

找到刚才解压缩的文件夹,选择jar包,然后点击OK,保存即可:

在右侧点击最上级的工程文件,然后右键 => Build Path => Configure Build Path...:

勾选后,点击完成,保存退出即可。我已经弄过了,所以我这里没办法点。

然后新建一个.java文件,输入以下代码即可验证是否成功连接MySQL。
import java.sql.*;
public class test05 {
public static void main(String args[]) {
Connection conn=null;
try {
Class.forName("com.mysql.cj.jdbc.Driver");
System.out.println("Success!");
}
catch (Exception e) {
System.out.print("Error!");
e.printStackTrace();
}
try {
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "debian-sys-maint", "VShIsIqvYFvcb5q1");
System.out.println("Success!");
conn.close();
}
catch (Exception e) {
System.out.print("get data error!");
e.printStackTrace();
}
}
}
输出以下结果便配置成功:

版权声明
本文为[我爱让机器学习]所创,转载请带上原文链接,感谢
https://blog.csdn.net/youngwyj/article/details/124293362
边栏推荐
- 开源免费,最好用的3大系统9大防火墙软件安利给你们
- 使用rpmbuild打包php
- 国内期货开户到哪个期货公司开更安全?
- [Chongqing Guangdong education] reference materials of management principles of Sichuan Agricultural University
- [leetcode daily question] rotation function
- [eight part essay] usage scenarios and features of JUC
- Learning Android VI from scratch -- data persistence
- 启牛商学院理财app下载是不是真的,在启牛开户安全吗
- Shenkaihong signed a cooperation agreement with Yisheng technology to jointly build a new ecosystem of business display industry
- 2021-06-10 axure本地发布
猜你喜欢

Obtain the real IP address of the client after envoy proxy

Open source, free and best used 3 systems and 9 firewall software Amway gives you

【H5】微信端H5页面制作

C develop OPC client

Uniapp product category tab

What kind of headphones do you wear for sports? The best equipment for running and listening to music

10.4.4 experiment of 8 LED "running lights" in 51 single chip microcomputer control system

What is the reason why the camera device with built-in 4G card of Haikang cannot register with easycvr platform?

【Leetcode-每日一题】旋转函数

. net using supersocket to build socket server
随机推荐
Speak through object prototype. toString. call()
How can I apply for new shares? Is it safe to apply for new shares?
网络隧道技术
嵌入式Web项目(一)——Web服务器的引入
Unable to log in to remote MySQL server 1045 error
DNS解析流程&基础知识
The origin explanation and use example of image pre training model
Analysis of three traversal filtering methods of JS
2018-8-10-win10-uwp-商业游戏-1.2.1
2022-01-12 微信小程序调试
光刻机巨头ASML爆料:芯片太缺,都开始拆洗衣机了!
顶测科技整理转行过程中一定要避免的问题
JS copy and paste, clipboard js
Influxdb deletes a piece of data according to time
2021应届毕业生该何去何从?
[Niuke brush question 19] MP3 cursor position
【牛客刷题19】MP3光标位置
calico官网网络拓扑实现:基于eNSP与VMVare
怎么才能申购新股呢?申购新股安全吗?
《PyTorch深度学习实践》08 加载数据集