大家都知道MySQL是一款中、小型关系型数据库管理系统,很具有实用性,对于我们学习很多技术都有帮助,前几天我分别装了SQLServer 2008和Oracle10g数据库,也用了JDBC去连接他们,都没有出现乱码。昨天看同学用java连接MySQL数据库的时候
看这篇博客挺好的,所以加上了MySQL的下载过程,希望对需要的人有所帮助:
1、首先在百度搜索MySQL,如图选择第一个搜索项,如图所示:
2、在打开的页面中,选择下图中的“download”连接,如图所示:

3.、对于MySQL的下载分为多个版本,我们只需要下载服务器就足够了。大约30M多,选择下图的连接,如图所示:

4、最后献上5.5.28这个服务器的下载连接地址:
http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.28-win32.msi
接下来是我的MySQL数据库服务器的安装步骤:
1、首先单击MySQL5.5.21的安装文件,出现该数据库的安装向导界面,单击“next”继续安装,如图所示:

2、在打开的窗口中,选择接受安装协议,单击“next”继续安装,如图所示:

3、在出现选择安装类型的窗口中,有“typical(默认)”、“Complete(完全)”、“Custom(用户自定义)”三个选项,我们选择“Custom”,因为通过自定义可以更加的让我们去熟悉它的安装过程,单击“next”继续安装,如图所示:

4、在出现自定义安装界面中选择mysql数据库的安装路径,这里我设置的是“d:Program FileMySQL”,单击“next”继续安装,如图所示:

5、接下来进入到准备安装的界面,首先确认一下先前的设置,如果有误,按“back”返回,没有错误,单击“Install”按钮继续安装,如图所示:

6、单击“Install”按钮之后出现如下正在安装的界面,经过很少的时间,MySQL数据库安装完成,出现完成MySQL安装的界面,如图所示:

这个界面单击“next”就行。


注意要选择上边的“Launch the MySQL Instance Configuration Wizard”选项,这是启动MySQL的配置,也是最关键的地方,单击“Finish”按钮,进入到配置界面。
7、MySQL数据库的安装十分简单,关键是安装完成之后的配置,单击完成之后出现如下的配置界面向导,单击“next”进行配置,如图所示:

8、在打开的配置类型窗口中选择配置的方式,“Detailed

9、在出现的窗口中,选择服务器的类型,“Developer Machine(开发测试类)”、“Server Machine(服务器类型)”、“Dedicated MySQL Server Machine(专门的数据库服务器)”,我们仅仅是用来学习和测试,默认就行,单击“next”继续,如图所示:

10、在出现的配置界面中选择mysql数据库的用途,“Multifunctional Database(通用多功能型)”、“Transactional Database Only(服务器类型)”、“Non-Transactional Database Only(非事务处理型)”,这里我选择的是第一项, 通用安装,单击“next”继续配置,如图所示:

11、在出现的界面中,进行对InnoDB Tablespace进行配置,就是为InnoDB 数据库文件选择一个存储空间,如果修改了,要记住位置,重装的时候要选择一样的地方,否则可能会造成数据库损坏,当然,对数据库做个备份就没问题了,如图所示:

12、在打开的页面中,选择mysql的访问量,同时连接的数目,“Decision Support(DSS)/OLAP(20个左右)”、“Online Transaction Processing(OLTP)(500个左右)”、“Manual Setting(手动设置,设置为15个)这里选择手动设置,单击“next”继续,如图所示:

13、在打开的页面中设置是否启用TCP/IP连接,设定端口,如果不启用,就只能在自己的机器上访问mysql数据库了,这也是连接java的操作,默认的端口是3306,并启用严格的语法设置,单击“next”继续,如图所示:

14、在打开的字符编码的页面中,设置mysql要使用的字符编码,第一个是西文编码,第二个是多字节的通用utf8编码,第三个是手动,我们选择utf-8,如果在这里没有选择UTF-8这个编码的化,在使用JDBC连接数据库的时候,便会出现乱码,到那时需要加上如下的代码“useUnicode=true&characterEncoding=UTF-8 ”,才可以解决乱码问题,为了以后的方便所以设置为UTF-8编码,但是有一个问题,那就是当用哪个控制台插入汉字的时候,会报错,查询带汉字的表时,无法显示汉字,所在需要在每次进入MySQL后,设置一个系统参数“set names

15、在打开的页面中选择是否将mysql安装为windows服务,还可以指定Service Name(服务标识名称),是否将mysql的bin目录加入到Windows PATH(加入后,就可以直接使用bin下的文件,而不用指出目录名,比如连接,“mysql–u username –p password;”就可以了,单击“next”继续配置,如图所示:

16、在打开的页面中设置是否要修改默认root用户(超级管理员)的密码(默认为空),“New root password”,如果要修改,就在此填入新密码,并启用root远程访问的功能,不要创建匿名用户,单击“next”继续配置,如图所示:

17、到这里所有的配置操作都已经完成,单击Execute按钮执行配置,如图所示:

18、过了几分钟,出现如下的提示界面就代表MySQL配置已经结束了,并提示了成功的信息。

19、在服务中将mysql数据库启动,并在命令窗口中输入“mysql–h localhost–u root -p”或者是“mysql -h localhost -uroot -p密码”,接着在出现的提示中输入用户的密码,如图所示:

从图中可以看到mysql数据库在启动之后,成功的登录了,在此我们可以对数据库进行操作了。
声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。