Linux安装MySQL数据库_第1页
Linux安装MySQL数据库_第2页
Linux安装MySQL数据库_第3页
Linux安装MySQL数据库_第4页
Linux安装MySQL数据库_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、数据库Mysql安装1首先下载安装包并使用命令tar解压:命令格式:tar -zxvf MySQL-versio n-OS.tar.gz我的操作:tar-zxvf mysql-5.1.30.tar.gzf root'dtest:"/domloadmysql-5. l.SO/plugin/fulltext/plug5 in example cmysql-5.1.30/plugin/fulltext/ChangeLogniysql-S 1 30/plugin/full text/Mak 已:Ei J.已inysql-5 1 30/plugin/full text/ deps/my

2、sql-5 1 30/plugin/ful1texxj dep3/myp1ug1ito_1a-p1ugin_examp 1已 Pio inysql-5 1 30/plugin/full text/inypluglib 丄氨xnysql-5.1 30/plugrin/£ulltxt/ itiysql-S. 1.30/plugin/full text / . libs/inypluglib_la-plugin_exaxnple oB1,30/plugin/full text/ B liJos/rayplugiiti B so B 0 B 0 B 0mysql-5 1 30/plugin/

3、full text/ J.ibs/myp 丄 u?丄 ib so 0mysql-5 1 3 0/plugin/fullt已就匸/丄ibs/myp丄uglib somysql-5 1 30/plugin/fulltext/1ib3/myp1ug1ib ainysql=S s 1 s 30/plugin/full text/ B1 itos/inyp lugl ib B laixnygql-5.1. SO/plugin/full text/ . 1 ibg/myp lul ib. lamysql-5.1 30/plugin/full text/myp lugl ib_la-plugin_examp

4、le. omysql-5 1 30/plugin/f ulltext/inyplugl ib_la-plugin_example lo mysql-S 1 3 0/plugin/Makef ile in mysql-5 :L 3 0/plugin/Makefile amrtiysql-5 1 3 0 / p lugin/ Makef i lexnyql-5.1 >30/eon£ig(i logmysql-S1.30/Makefliemysql-S fl 1 fl 30/ liJotoolmysql-5 1 30/configB statusroottest download#

5、|使用cd命令进入解压后的目录 命令格式:cd MySQL-versio n-OS口download# cd mysql-5,130 root0test itiysql-5 »1,30 #./configure之前要make clean 下吧,为什么,好像是防止原来编译过raotGtest imysql-5 1.3口# wake cleanf注释:在执行" make clean”失败时,提示错误 checking for termcap functions library.con figure: error: No curses/termcap library found

6、。则在执行./configure命令,执行命令代码为:./c on figure-prefix=/usr/share/mysql/ -with-charset=utf8 -with-extra-charsets=all-vith-named-curses-libs=/usr/lib/lib ncursesw.so.5(最后一段命令可以省略)出现错误:No curses/termcap library found 或者 see the install manual chapter in thereferenceyum install gcc yum install ncurses-devel2.

7、 配置和编译安装环境2.1配置安装环境命令格式:./c on figurerefix=安装路径-prefix=/usr/local/mysql/ 安装到此目录下我的操作:./configure-prefix=/usr/local/mysql/-with-charset=gbk -with-extra-charsets=all力口入解决中文乱码./con figure -prefix=/usr/share/mysql/ -with-charset=gbk -with-extra-charsets=allrootBtest mysql-5-1>3 # /configure -prefix&#

8、171;/use/local/mysql/参数:-prefix=指软件安装的路径config.statusi config status: config, stoitus t config.status 2 config.status; config.status: config.status: config* status: config status: config.statusi config status:crediting creating cresting creating creating creating creat- ing creatingmysql-test/Make&#

9、163; ilg inysql-test/ ndb/ Makef i le ne t war e/ile scl-be nch/ Make file inc 1 ude/mysq 1 version, h plugin/Makefile win/Makef ile include/coni ig-hinclude/config h is uzichainged executing depfiles commands executing default conmandsMySQL more productiveThere you can also find imiling lis壬口匕MySQL

10、 discussi口眾.;atioutRemeiriber to hints 工壬丄皂sthe platform specific part, of the ref已匸亡工lc:已 manual forcheckinstalling KySQL on your platform. Also have a look at theaboutin the Docs directoryThankyou for 匚hooaing HySQL !MySQL has a Ueb site atr http: /wwu.血尹日口丄匚口诃 which 匚arri皂占 details on 匸he: latest

11、 release, upcoming featui:esf and other information toyourwork or play with information2.2编译安装环境命令格式:make执行 make命令时出现错误: exec g+ not found安装 gcc -c+重新执行上一命令(con fig)roor c皀書匸 mysql-5 * 1 3口# mahe等待.时间太长了 2.3安装命令格式: make in stallrootGtest mysql-S.1.30# make install3. 创建MySQL相关用户使用命令groupadd创建用户组 命令格式

12、:groupadd mysqlrootQtest raysql-5*1.30# groupadd myscjl使用命令useradd创建用户并分配到mysql组中命令格式:useradd - g mysql mysqlroot t皂号it mysql=5 . 1.30# iiseradd -g mysql mysql|使用命令passwd修改用户密码 命令格式:passwd mysqlrootr0匸皂mysql-5,1.30 passud mysql Changing password for user mysq1.Meu password:BAD PASSWORD: it is based

13、on a dietionary word 罠皀匸ype nw password:passwd: all aut-hen'tication tokens updated successfulLy.我的密码:password4配置MySQL数据库环境4.1. 使用命令cp拷贝示例配置文件到系统环境 命令格式:此步骤在解压的目录/etc/my.c nfcp ./support-files/my-medium.c nf|匸口皂st 甜y目qJL-S * 1 30 # 三戸 /nupp口匚匸一:f iJLe:/my-m皂f /丘匚匚/甜¥ cnf |拷贝目标文件 f必须要这样命名,该名

14、称为数据库默认配置文件。4.2. 使用命令VI编辑配置文件命令格式:vi/etc/froottest mysql-5,1,30 # vi /etc/mycnf查找/skip/后面为查找内容回区Example MySQL config f il 皂 for medium systeins»This is £口上 system with little mgwry (32H - 64M) where HySQL. plays an irnportant part or systems up co 128H where MySQL is used together ulth oth

15、er programs (such as a neb server)Yau can copy this file to/etc/my. cnf to set g丄口 bal opt ions,my s q 1 - da t a- d! ir/ my B c nf to set server-specific! options ( in this installation this directory is /use/local/mysql/vai:) or m/f to set user-specific options.In this file you cars use all long o

16、ptions that a progretmi suppo-rtsBIf you want to know which dplsions a program supportsr run the program with the rr一一helprr oiption.# The fol丄OMing options vill be passed to all MySQL clients client-yow password 3306"= /tmp/mysql.sockSfpassuordportsocket结 Here follows entries for some specific

17、 programs /skip查找skip-federated选项是否打开,把它注释掉。# required# defaults# but will:uijrnyiswi sort buffer size s 8M# Don1 z lis匸已n oil a TCP/ IP port at all This ean I已 a security enhancement# if 么丄丄 processes that need to connect to mysqld run on the same host # All interaction Mith mysqld itiinst; be itia

18、d已 via Unix sockets or named pipes.# Note tha匸 using this option without enabling named pipes on Uindows# the "呂iiatiJ.电一旦" option) willniyqld wele !#sklp-networking# Disable Federated by default #skip-federated# Replication Has ter Servei: (default)珈 binary legging is required ±or re

19、plication1 o g-b in=mys ql-Join # bi nary logging forroat 一 rtiixed recommeiiLled binlog :f口rmat=ittixed unique id between 1 and 2A32 - 1to 1 i£ maat&rhosi: is not set not function as a master if omitted并保存退出5初始化系统数据库5.1.使用命令 cd进入安装目录 也就是上面的/user/local/mysql命令格式:cd /$MYSQL_HOME如果使用参数一prefix

20、则进入参数指定路径,否则进入/usr/local默认路径查找rcottest, imysql-5.1.30# cd /use/local/mysql/5.2. 使用命令chown修改安装目录权限命令格式:chown -R mysql:root .代表在当前目录及其下面的内容Eroot.Bt.est.mysql M chown-R mysql:root *rcotg testmysql11total 32drwxr-xr-x2tnyaqlroo匸4096J an612 ;13drwxr-xr-x2msqlroot4096Jan612 i118drvxr-xr-x3myaqlroot4096J a

21、nE12 :18cirvxt-xr-x3ttiysqlroot斗096J an612 :18drwxr-xr-x2my3qlroo匸4096J an612 :19druxr-xr-x10msqlroot409£Jan612 :19drwxr-xr-x5mysqlroot4096J an612 :19drvxr-xr-x5mysqlroot4096Jan612::19itiysql tf5.3.初始化系统数据库命令格式:bin/mysql_ in stall_db -user=mysqlroottest rtiysql t) in/mysql instal 1 db -user =in

22、ysql|显示一些帮助信息/usr/ Iccal/rtiysql/to in/mysqladinin -u root- password 1 new-passworti1/use/lccal/mysql/bin/inysqladinin -u root -h test password 1 neu-password1A丄cernatively you can run:/usr/local/Hiysql/bin/inysqi secure installationwhich uill also giv& you the option of removing the test databa

23、ses and anonymous user created Joy default-. This im strongly recoMtiended for production servers,See the manual for mor 已 inmt匸 nut icms .You can start the MySQL daemon with:cd /usr/ local/inysq丄;/usr/ loca丄命l/bin/tnymqtlci sale &You can test the KySOL daeruDii with mysql一t已st-run. pl od /usr/l

24、ocal/raysql/mysql-cest ; perl mysql-test-run*plP丄ease report any prob丄亡mm with the /usr/local/tnys-L/feln/ftivsqlbug script!The latest information atoout MySQL is aval lab le at. littp : /www.niyaql. conn/Support MySQL by buying support/licenses from http:/shop,niysql-com/LootlJ tear itiy3 :ii#6修改数据

25、库安全性6.1修改数据库文件夹权限命令格式:chown - R mysql varvar为数据库默认的数据文件夹,文件夹名称以实际情况而定rcottestmysql# chown-R hi3q丄 varroot testmysiq 丄# 11total 6druxr-xr-x2mysqlroot4D96Jandruxr-xr-x2mysqlroot409 6Jandrwxr-Xt-x3Dfyaq 1root409 6Jan3mysqlroot09 &Jandrwxr-xr-xZmysqlroot4D96Jandrwxr-xr-xIDmysqlroot409 6Jandrvxr-xr-y

26、5mysqlroot409 SJ andrwxr-xr-5mysqlcoot409 6Jandtwx-4niysql匸st09SJan6 12:186 12:18e 12:is6 12:136 12:196 12:196 12:196 12:196 12:256.2启动服务并修改root用户密码命令格式:bin/mysqld_safe - user=mysql &ro口匸亡曰t mysql席 bin/wysqld safe -U3er=rtiysql &1 198S8rootdtest raysql # 100106 12 : 27:24 naysq 1 d_safe Logg

27、ing to 1 /use/ local/mysql/var/ test B err 1 .100106 12 :27:24 mysqldsafe Staircing mysqld daenton 坊ith databases from /user / loca1/mysql/vairbin/mysqladmin - u root passwordrocttest mysc|l # bin/mysqladiriin -u root password下面是一些修改命令,也可不看bin/mysqladmin - u root - h $hostname password ''PLE

28、ASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, the n issue the followi ng comma nds:修改root的登入密码/usr/local/mysql/b in/mysqladm in -u root password 'n ew-password 修改test密码/usr/local/mysql/b in/mysqladm in -u root -h test password 'n ew-password'You can

29、start the MySQL daemon with:cd /usr/local/mysql ; /usr/local/mysql/b in/mysqld_safe &7测试数据库命令格式:bin/mysql - u root - prootScest wysqlbin/mysql -u root -pEnter passvocd:Uelcaime to the MySQL ironicor« Ctmnmatids end with ; or Your MySQL connect.ion id is 2Server version: 5,1.30-log Source di

30、stributionType 'help;1 or 1h* for help * Type 1c1 to clear the buffer * m站羽"密码为空Mysql 语句:show databases;mysql> show databases; I卜IDatabase|+|infcrmation scheina |ImvsqlI|test|l卜3 rous in set (0.01mysql>退出ctrl+c bye或者exit依环境的不同而定下面的一直没有用到使外部客户端连接到MySQL,先登录到MySQL服务器端:格式:grant权限on数据库对象to

31、用户mysql>grant all on *.* tofoot''%'identified by rbot 密码'1拷贝数据库启动脚本到安装目录命令格式:cp /MySQL-versio n-OS/support-files/mysql.server/$MySQL_HOME/bi n/mysql.serverroot0tesc imysqlj # cp / root./dowiiload/iwy3qL-5 -1.30/support-f i les/inysql» server /usr/local/itiysql./tiin/mysql.ser

32、ve我的操作:cp /root/dow nload/mysql-5.1.30/support-files/mysql.server/usr/local/mysql/b in/mysql.server2. 修改执行权限命令格式:chmod 755 /$MySQL_HOME/bi n/mysql.serverroot test mysql # cbimotl 755 / usr/local/mysql/birL/mysql. server命令解释:chmod是Linux下设置文件权限的命令,后面的数字表示不同用户或用户组的权 限。一般是三个数字:第一个数字表示文件所有者的权限第二个数字表示与文件所

33、有者同属一个用户组的其他用户的权限第三个数字表示其它用户组的权限。权限分为三种: 读(r=4 ),写(w=2),执行 (x=1)。综合起来还有可读可执行(rx=5=4+1 )、可读可写(rw=6=4+2)、可读可写可执行 (rwx=7=4+2+1)。所以,chmod 755设置用户的权限为:1. 文件所有者可读可写可执行2. 与文件所有者同属一个用户组的其他用户可读可执行3. 其它用户组可读可执行chmod 4755 与chmod 755的区别在于开头多了一位,这个4表示其他用户执行文件时,具有与所有者相当的权限。例如:root用户创建了一个上网认证程序netlogin ,如果其他用户要上网也

34、要用到这个程序,那就需要root用户运行chmod755 netlogin 命令使其他用户也能运行netlogin但是netlogin 执行时可能需要访问一些只有root用户才有权访问的文件,那么其他用户执行netlogin 时可能因为权限不够还是不能上网。这种情况下,就可以用chmod 4755 netlogin 设置其他用户在执行n etlogin 也有root用户的权限,从而顺利上网。3使用方法mysql.server start|stop|restartrooc test mysql # /usr/ local/tmysql/bin/mysql .server start Starri

35、ng HySQL SUCCESS!/etc/profileecho $PATH4. 修改环境变量让mysql.server在何地都能执行vi /etc/profileroottest mysqlS vi /etc/pro£ileMYSQL_HOME=/usr/local/mysqlPATH=$PATH:$MYSQL_HOME/binexport MYSQL_HOME PATH 注意这里export必须为小写conf igureHYSQLHOME'/usr/local/mysql PATH=?PAT:i: SKYSQL_HOMI:/bin export HYSQLHOMEPATHsource /etc/profile重

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论