mysql如何安装
工具/原料
MySQL安装程序:mysql-5038-win32msi 步骤/方法
1、打开下载的安装文件
2、mysql安装向导启动,点击“next”继续。
3、选择安装类型,有“Typical(默认)”、“Complete(完全)”、“Custom(用户自定义)”三个选项,我们选择“Custom”,有更多的选项,也方便熟悉安装过程。
4、在“MySQL Server(MySQL服务器)”上左键单击,选择“This feature, and all subfeatures, will be installed on local hard drive”,即“此部分,及下属子部分内容,全部安装在本地硬盘上”。点选“Change”,手动指定安装目录。
5、确认一下先前的设置,如果有误,按“Back”返回重做。按“Install”开始安装。
6、正在安装中,请稍候。
7、点击“next”继续。
8、现在软件安装完成了,出现上面的界面,这里有一个很好的功能,mysql 配置向导,不用向以前一样,自己手动乱七八糟的配置myini 了,将“Configure the Mysql Server now”前面的勾打上,点“Finish”结束软件的安装并启动mysql配置向导。
9、点击“Finsh”,出现如下界面,MySQL Server配置向导启动。
10、点击“next”:
11、选择配置方式,“Detailed Configuration(手动精确配置)”、“Standard Configuration(标准配置)”,我们选择“Detailed Configuration”,方便熟悉配置过程。
12、选择服务器类型,“Developer Machine(开发测试类,mysql 占用很少资源)”、“Server Machine(服务器类型,mysql占用较多资源)”、“Dedicated MySQL Server Machine(专门的数据库服务器,mysql占用所有可用资源)”,大家根据自己的类型选择了,一般选“Server Machine”,不会太少,也不会占满。
13、选择mysql数据库的大致用途,“Multifunctional Database(通用多功能型,好)”、“Transactional Database Only(服务器类型,专注于事务处理,一般)”、“Non-Transactional Database Only(非事务处理型,较简单,主要做一些监控、记数用,对MyISAM数据类型的支持仅限于non-transactional),随自己的用途而选择了,我这里选择“Transactional Database Only”,按“Next”继续。
14、对InnoDB Tablespace进行配置,就是为InnoDB 数据库文件选择一个存储空间,如果修改了,要记住位置,重装的时候要选择一样的地方,否则可能会造成数据库损坏,当然,对数据库做个备份就没问题了,这里不详述。我这里没有修改,使用默认位置,直接按“Next”继续。
15、选择您的网站的一般mysql 访问量,同时连接的数目,“Decision Support(DSS)/OLAP(20个左右)”、“Online Transaction Processing(OLTP)(500个左右)”、“Manual Setting(手动设置,自己输一个数)”,我这里选“Online Transaction Processing(OLTP)”,自己的服务器,应该够用了,按“Next”继续。
16、是否启用TCP/IP连接,设定端口,如果不启用,就只能在自己的机器上访问mysql 数据库了,我这里启用,把前面的勾打上,Port Number:3306,在这个页面上,您还可以选择“启用标准模式”Enable Strict Mode),这样MySQL就不会允许细小的语法错误。如果您还是个新手,我建议您取消标准模式以减少麻烦。但熟悉MySQL以后,尽量使用标准模式,因为它可以降低有害数据进入数据库的可能性。还有一个关于防火墙的设置“Add firewall exception ……”需要选中,将MYSQL服务的监听端口加为windows防火墙例外,避免防火墙阻断。按“Next”继续。
17、注意:如果要用原来数据库的数据,最好能确定原来数据库用的是什么编码,如果这里设置的编码和原来数据库数据的编码不一致,在使用的时候可能会出现乱码。这个比较重要,就是对mysql默认数据库语言编码进行设置,第一个是西文编码,第二个是多字节的通用utf8编码,都不是我们通用的编码,这里选择第三个,然后在Character Set 那里选择或填入“gbk”,当然也可以用“gb2312”,区别就是gbk的字库容量大,包括了gb2312的所有汉字,并且加上了繁体字、和其它乱七八糟的字——使用mysql 的时候,在执行数据操作命令之前运行一次“SET NAMES GBK;”(运行一次就行了,GBK可以替换为其它值,视这里的设置而定),就可以正常的使用汉字(或其它文字)了,否则不能正常显示汉字。按“Next”继续。
18、选择是否将mysql 安装为windows服务,还可以指定Service Name(服务标识名称),是否将mysql的bin目录加入到Windows PATH(加入后,就可以直接使用bin下的文件,而不用指出目录名,比如连接,“mysqlexe -uusername -ppassword;”就可以了,不用指出mysqlexe的完整地址,很方便),我这里全部打上了勾,Service Name不变。按“Next”继续。
19、这一步询问是否要修改默认root 用户(超级管理)的密码(默认为空),“New root password”如果要修改,就在此填入新密码(如果是重装,并且之前已经设置了密码,在这里更改密码可能会出错,请留空,并将“Modify Security Settings”前面的勾去掉,安装配置完成后另行修改密码),“Confirm(再输一遍)”内再填一次,防止输错。“Enable root access from remotemachines(是否允许root 用户在其它的机器上登陆,如果要安全,就不要勾上,如果要方便,就勾上它)”。最后“Create An Anonymous Account(新建一个匿名用户,匿名用户可以连接数据库,不能操作数据,包括查询)”,一般就不用勾了,设置完毕,按“Next”继续。
20、确认设置无误,如果有误,按“Back”返回检查。按“Execute”使设置生效。设置完毕,按“Finish”结束mysql的安装与配置。
注意事项
这里有一个比较常见的错误,就是不能“Startservice”,一般出现在以前有安装mysql 的服务器上,解决的办法,先保证以前安装的mysql 服务器彻底卸载掉了;不行的话,检查是否按上面一步所说,之前的密码是否有修改,照上面的操作;如果依然不行,将mysql 安装目录下的data文件夹备份,然后删除,在安装完成后,将安装生成的data文件夹删除,备份的data文件夹移回来,再重启mysql 服务就可以了,这种情况下,可能需要将数据库检查一下,然后修复一次,防止数据出错。
1、首先下载MySQL的安装文件,我这里安装的是MySQL517版本的,
2、安装MySQL数据库服务器
进入安装包所在文件夹,执行命令 rpm -ivh MySQL-server-517-0i386rpm 安装MySQL服务器。
如果报了与原先版本冲突的话,就执行rpm -qa|grep -i mysql命令,会显示已安装的Mysql版本,我的显示mysql-libs-5161-4el6i686
这时如果有的话就强制删除:rpm -e --nodeps mysql-libs-5161-4el6i686(因为有包依赖,所以要强制删除)
我的报错提示如下:
复制代码
代码如下:
MySQL-server-517-0i386rpm
Preparing ########################################### [100%]
file /usr/share/mysql/charsets/README from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/Indexxml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/armscii8xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/asciixml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/cp1250xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/cp1251xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/cp1256xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/cp1257xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/cp850xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/cp852xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/cp866xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/dec8xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/geostd8xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/greekxml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/hebrewxml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/hp8xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/keybcs2xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/koi8rxml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/koi8uxml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/latin1xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/latin2xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/latin5xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/latin7xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/maccexml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/macromanxml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/charsets/swe7xml from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/czech/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/danish/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/dutch/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/english/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/estonian/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/french/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/german/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/greek/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/hungarian/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/italian/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/japanese/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/korean/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/norwegian-ny/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/norwegian/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/polish/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/portuguese/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/romanian/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/russian/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/serbian/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/slovak/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/spanish/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/swedish/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
file /usr/share/mysql/ukrainian/errmsgsys from install of MySQL-server-517-0i386rpm conflicts with file from package mysql-libs-5161-4el6i686
这时候再执行rpm -ivh MySQL-server-517-0i386rpm安装即可安装成功。
我这里安装成功了,但是mysql服务无法启动,总是启动失败,后来百度了一下,是因为selinux的原因,只要将selinux关闭就OK了。
关闭selinux:vi /etc/selinux/config 将SELINUX=enforcing 改成SELINUX=disabled 然后重启
关闭selinux之后还是无法启动mysql服务,因为安装的mysql所有者是root,在安装mysql的时候会创建一个用户mysql,只要将/var/lib/mysql
的所有者改为mysql就OK了,执行命令chown -R mysql:mysql /var/lib/mysql
现在执行service mysql start终于可以启动mysql服务了。
3安装MySQL客户端
执行命令rpm -ivh MySQL-client-517-0i386rpm进行安装。
4安装成功
成功安装MySQL后将sql文件导入到数据库,步骤如下:
进入MYSQL Command Line Client
1、先创建数据库:create database test 注:test是创建数据库的名称
2、再切换到当前数据库:use test
3、再输入:/ /root/testsql 或 souce /root/testsql
按照以上步骤就可以将备份的sql脚本导入到linux中的数据库中去。
方法/步骤
1、刚刚接触mysql数据的人,第一步新建数据库,可打开phpmyadmin;
2、然后选择数据库菜单;
3、点击sql菜单;
4、在输入框中输入下面语句
create database 数据库名;
最后点执行,新数据库就建好了。
这种架构一般用在以下三类场景
1 备份多台 Server 的数据到一台如果按照数据切分方向来讲,那就是垂直切分。比如图 2,业务 A、B、C、D 是之前拆分好的业务,现在需要把这些拆分好的业务汇总起来备份,那这种需求也很适用于多源复制架构。实现方法我大概描述下:业务 A、B、C、D 分别位于 4 台 Server,每台 Server 分别有一个数据库来隔离前端的业务数据,那这样,在从库就能把四台业务的数据全部汇总起来,而不需要做额外的操作。那没有多源复制之前,要实现这类需求,只能在汇总机器上搭建多个 MySQL 实例,那这样势必会涉及到跨库关联的问题,不但性能急剧下降,管理多个实例也没有单台来的容易。
2 用来聚合前端多个 Server 的分片数据。
同样,按照数据切分方向来讲,属于水平切分。比如图 3,按照年份拆分好的数据,要做一个汇总数据展现,那这种架构也非常合适。实现方法稍微复杂些:比如所有 Server 共享同一数据库和表,一般为了开发极端透明,前端配置有分库分表的中间件,比如爱可生的 DBLE。
3 汇总并合并多个 Server 的数据
第三类和第一种场景类似。不一样的是不仅仅是数据需要汇总到目标端,还得合并这些数据,这就比第一种来的相对复杂些。比如图 4,那这样的需求,是不是也适合多源复制呢?答案是 YES。那具体怎么做呢?
mysql安装教程:1、双击下载的 MySQL 安装文件。2、进入“Choosing a Setup Type窗口,选择合适自己的安装类型。3、点击Execute 按钮,自动完成框架安装。4、框架都安装好了,点击确认。5、开始安装组件。6、开始安装MySQL 文件,文件安装好了列表会显示安装成功。
现在作为服务器的操作系统一般有两种,分别是 Windows Server 和 Linux,在 Windows 系统上安装MySQL Windows 平台下提供两种安装 MySQL 的方式:MySQL 二进制分发版(msi 安装文件)。免安装版(zip 压缩文件)。安装 MySQL 的具体步骤如下:
1、双击下载的 MySQL 安装文件,进入 MySQL 安装界面,首先进入“License Agreement(用户许可证协议)”窗口,选中“I accept the license terms(我接受系统协议)”复选框,单击“Next(下一步)”按钮。
2、进入“Choosing a Setup Type(安装类型选择)”窗口,选择合适自己的安装类型。
3、单击 Execute 按钮,自动完成框架安装。
4、所需框架均安装成功后,单击Next。
5、进入安装确认窗口,单击 “Execute(执行)”按钮,开始 MySQL 各个组件的安装。
6、开始安装MySQL 文件,安装完成后在“Status(状态)”列表显示“Complete(安装成功)”。
0条评论