




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Java实验6-MySql的安装与连接MySql数据库数据库连接成功后的结果:您也成功连接MySQI数据库,以下是您的数据库信息!学号姓名学校性别课程2011001张三丰吉首大学男太极拳2011002张无忌吉首大学男乾坤大罗移2011003小龙女吉首大学女玉女剑法2011004东方不败吉首大学女葵花宝典2011005令狐冲吉首大学男独孤九剑”详细操作步骤:第一:先下载并 安装MySql nl oads/mysql打开下载的 mysql安装文件mysql-5.5.15-win64.zip,双击解压缩,运行“setup.exe ”,出现如下界面:需1 MySQL Server 5.5 SetupB
2、ackNextCanc&lWelcome to the MySQL Server 5.5 Setup WizardThe Setup Wizard will install MySQL Server 5*5 on your computer. Click 忖乜xt to continue or Cancel to exit the 5etup Wizard.Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved!.mysql安装向导启动,按“ Next继续:剧 MySQL Server 5.5 Se
3、tupEnd-User License AgreementPlease read the following license agreement carefully按“ Next ”继续:冉 MySQL Server 55 Setup选择安装类型,有“ Typical (默认)”、“ Complete (完全)”、Custom (用户自定义)”三个选项,我们选择“ Custom,出现下图所示界面:按“Next”继续,出现下图:刃 MySQL Server 5,5 Setup点击“install ”以继续,出现下图界面:MySQL Server 5.5 SetupInstalling MySQL
4、 Server 5-5Plea&a wart whil$ the Setup Wizard dnstalls MySQL Server 5.5.Status:Copylmg new filesBackIM&xtCancel按“ Next继续,出现下图:MySQL EnterpriseA MySQL Enterprise subscription (s the most comprehensive offering of MySQL database software, service and support to ensure your business achieves theh Ighes
5、t leveis of reliabil security, and uptime.An Enterprise Subscription indudes:L The MySQL Enterprise Server-The most reliable, secure, and up-to-date version of the worlds most popular open source database.2. MySQL Enterprise Monitor Srvk?-An automated virtual database assistant3 MySQL Production Sup
6、port - Technical and consultative support when you need 也 along wtth service packs, hobfixesr and more.isiiiiNujjiui II*;- jp同egw丄逖賦汕胡亓弓还”】亓卑筑商1迤崽More .Cancel按“ finish ”完成安装MySQL Server Instance Configuration WizardWelcome to the MySQL Server Instance ConfiQuration Wizard 1hOJ7.0Next a | 匚ancdThe Co
7、nfiguration Wizard will allow you to configure the MySQL Server 5.5 server instance. T Continue, dick Next.mysql配置向导启动界面,按“ Next继续MySQL Server Instance Configuration WizardMySQL Server Instance ConfiguratkinConfigure the MySQL Server 5.5 server instance.Detailed ConfigurationPlease select 日 configur
8、ation typE,server匚hooie this configuration type to create the optimal setup for this machine.Standard ConfigurationUse this only on machines that do not already have a MySQL ierver installation. This will u$e a general purpc亡 configuration for the server that can be tuned manually. BackCancel程。Pleas
9、e select the database usage.General purpose databases. This will optimize the server for the ue 皀 of the fast transactional InnoDB sto rage engine and the high speed MylSAM borage engine.1 Transactional Database OnlyOptimized for application servers and transactional web applications. This will make
10、 InnoDB the main storage engine 八八Note that the MylSAM engiine can still be选择配置方式,“ Detailed Con figuratio n(手动精确配置)”Con figuratio n,”方便熟悉配置过.j-IUI JIMMIbll-lMIMUI-IUUIMI-ll_IUMIUUiaiUUI.IUiaiUMII Multrhinctional DatabaseCancelStan dard Con figurati on(标准配置)”,我们选择“DetailedMySQL Server Instance Confi
11、guration WizardMySQL Server Instance ConfigurationConfigure the MySQL Server 55 server instance;Non -Transactional Database OnlySuited for simple web application monitoring or logging applications si w亡II analyst programs, Only the non-transactional MylSAM storage engine will be activated.MySQL Serv
12、er Instance Configuration Wizard这里不要理睬,继续Next:选择网站的一般mysql访问量,同时连接的数目,这里选 ManualSetting ”,选择20个,按“ Next继续:MySQL Server Instance Con figuration WizardMySQL Server Instance ConfigurationConfigure the MySQL Server 55 server instance.Please set the networking options7 Enable TCP/IP NetworkingPort Number
13、Enable this to allow TCP/IP connections. vVhen disabled, only local connectionE through nanriEd pipes are allowed.Add firewall etc eption fcrthis porPlease set the server SQL mode.J Enable Strict NodeThis option forces the server to behave more like a traditional database server It i$ recommended to
14、 enable this option* I Cancel是否启用TCP/IP连接,设定端口,如果不启用,就只能在自己的机器上访问mysql数据库了,我这里启用,把前面的勾打上,Port Number : 3306,在这个页面上,选择 启用标准模式”(Enable Strict Mode ),按 “ Next 继续:这个比较重要,就是对 mysql默认数据库语言编码进行设置,第一个是西文编码,第二个是多字节的通用 utf8编码,都不是我们通用 的编码,这里选择第三个,然后在 Character Set 那里选择或填入“gbk,”当然也可以用“ gb2312 :区别就是gbk的字库容量大,包 括
15、了 gb2312的所有汉字,并且加上了繁体字、和其它乱七八糟的 字使用mysql的时候,在执行数据操作命令之前运行一次“SETNAMES GBK; ” (运行一次就行了, GBK可以替换为其它值,视这里的设置而定),就可以正常的使用汉字(或其它文字)了,否则不 能正常显示汉字。按“ Next ”继续。选择是否将mysql安装为windows服务,还可以指定Service Name (服务标识名称),是否将 mysql的bin目录加入 到Windows PATH (加入后,就可以直接使用 bin下的文件,而不 用指出目录名,比如连接, “mysql.exe -uusername-ppasswor
16、d; ”就可以了,不用指出 mysql.exe 的完整地址,很方 便),这里全部打上了勾,Service Name 不变。按“Next”继续。New root password;Confirm:Enter the root paword.Retype the paEsword.MySQL Server Instance Configuration WizardMySQL Server Instance ConfigurationConfigure the MySQL Server 5.5 server instance.Please set the security options. 屛 Mo
17、dify SecuritY Settings BackNextC ancelEnable root acc亡ss from remote m自thin亡丫Create Ar Ananyrnous AccointThis option will create an anonymous account on this server, Please note that this can lead to an insecure system,这一步询问是否要修改默认root用户(超级管理)的密码(默认为 空),在此填入新密码,“Confirm (再输一遍)”内再填一次,最后“ Create An An
18、onymous Account (新建一个匿名用户,匿名用户 可以连接数据库,不能操作数据,包括查询) ”,一般就不用勾了, 设置完毕,按“ Next继续。MySQL Server Instance Configuration WizardMySQL Server nstarKe ConfigurationConfigure the MySQL Server5.5 server instance.Processing configuration .M Prepare configurationM Write configuration file (Cf.prugp- Fife MySQLMvS
19、QL Server 5”5W/.ini)M Start serviceJ Apply security settingsConfiguration file created*Windows servke MySQL installed* Service wtrted successfully.Press Finish to close the Wizard,BackCancel确认设置无误,如果有误,按 “ Back”返回检查。按“ Execute ”使设 置生效。第二:下载MySql的jdbc驱动。 nloads/c onn ector/j/第三:将现下载好的jdbc驱动包导入eclipse
20、中去,操作如下-ZVo-r MVS CJL,I IVP* HI*E*rB-uillda-rAi Ib1 PbBkfaUo曰 5-tylwJ JhVJh COrFVhl l*J.V*.ToC LiO-iCAKi-a-niPb*IRL*i* g rvtrti h-h i - T *ck R/戸qmJvqitvTTsn y V*lsdartaia-rBUVIklT* 斫-IAE. nd 匸1.fC曰! Qn 七ti bulcj |38员1*1.第四:使用mysql创建数据库并加载数据mH MySQL 5.5 Command Line- Client.r- Crmni9 牛m 右 1?.QiX# ep
21、n :L=oH Gfeewitp嘱番 旺!*1丘Ivouii* FliJiiQiL conoecX: oo d. sK m a*2 m r UH itsk Jnin X E e 5Fly Kt 01 Oaa vniHii.n 汕11 y Rm mj严圧卫丄a is a.*-r阳扎3:i:e Jrtd ibAflrt-OLi.bl t r-ndiBi r tsu of t he ir* 日砂 pwr Vt d_ vngni起up -mysql use test;Database cha ngedmysql create table stude nt (- sno char(7) not n ul
22、l,- sn ame varchar(8) not nu II,-sid varchar(8) not n ull,- sex char(2) not nu II,-course varchar(9) not null- );1)给表添加内容:mysql insert in to stude nt values- (2011001,张三丰,吉首大学,男,太极拳);mysql insert in to stude nt values-(2011002,张无忌,吉首大学,男,乾坤大罗移);mysql insert in to stude nt values- (2011003,小龙女,吉首大学,女
23、,玉女剑法);mysql insert in to stude nt values- (2011004,东方不败,吉首大学,女,葵花宝典);mysql insert in to stude nt values- (2011005,令狐冲,吉首大学,男,独孤九剑);2)显示表的内容mysql select * from stude nt;曲 MySQL 5,5 Command Line Client也,东方环收洁首大学T女,癸亿玉典9詆Hns 1 iysql inisert into student values- 2011004, 东方不败J #吉苜大学,女J,葵花宝典J; !uery OK,
24、 1 row affected iysql inisert into stuident values- 20H0K. 1令狐冲J,吉首犬学男-*独孤九創T luery OK, 1 rou affected iysql select * fron student;snosnanesexcourseI 2O11I3B15 2011002! 2011003I; 2011004! 2011005男男女-IXBR吗盂1盂$子大大大大大败 丰忌女不神 三无龙轟 张张八英宅王九 太乾玉聶i rows in set (I3.0 gee)iysql第五:打开eclipse输入下面源代码:package date
25、;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;public class JDBCTest public static void main(String args)try /加载驱动程序Class. forName (com.mysql.jdbc.Driver );/ URL指向要访问的数据库名testStri ng url =jdbc:mysql:/:3306/test;/ MySQL配置时的用户名String user = root;/ MySQL配置时的密码String password =123;/连续数据库Conn ecti on conn ecti on 二DriverMa nager.getC onn ecti on (url, user, password);if (!connection.isClosed()System. out .println(”您也成功连接MySQI数据库,以下是您的数据库信息!);/ statement用来执行SQL语句Stateme nt sta
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 工业废弃物处理的物联网解决方案
- 工业旅游的规划与实施
- 工业机器人系统的集成与优化
- 工业机器人技术进展及影响
- 工业生态化改造与实践案例分析
- 工业能源管理与自动化控制技术
- 工业设备智能化升级解决方案
- 工业自动化中的语音控制技术应用
- 工业设计中的师徒智慧-产品设计专业成长
- 工作与生活平衡与员工福利设计
- TSG-T7001-2023电梯监督检验和定期检验规则宣贯解读
- 工业机器人系统操作员国家职业技能考核标准(2023年版)
- 万科物业管理公司员工手册
- 机器学习在教育领域的应用研究
- 一例ANCA相关性血管炎患者的护理查房
- 2024年全国初中数学联合竞赛试题参考答案及评分标准
- 海洋波浪发电课件
- 八年级数学下册 期末考试卷(湘教版)
- 2024年甘肃金川集团股份有限公司招聘笔试参考题库含答案解析
- 注册安全工程师继续教育题库
- 工程项目监理人工智能与机器人技术应用
评论
0/150
提交评论