mysql默认安装目录说明

转自http://blog.sina.com.cn/s/blog_48a770da0100oond.html

MySQL安装完成后不象SQL<wbr>Server默认安装在一个目录,它的数据库文件、配置文件和命令文件分别在不同的目录,了解这些目录非常重要,尤其对于Linux的初学者,因为<wbr>Linux本身的目录结构就比较复杂,如果搞不清楚MySQL的安装目录那就无从谈起深入学习。</wbr></wbr>

<wbr><wbr>下面就介绍一下这几个目录。<br style="line-height:22px"><wbr><wbr>1、数据库目录<br style="line-height:22px"><wbr><wbr>/var/lib/mysql/<br style="line-height:22px"><wbr><wbr>2、配置文件<br style="line-height:22px"><wbr><wbr>/usr/share/mysql(mysql.server命令及配置文件)<br style="line-height:22px"><wbr><wbr>3、相关命令<br style="line-height:22px"><wbr><wbr>/usr/bin(mysqladmin<wbr>mysqldump等命令)<br style="line-height:22px"><wbr><wbr>4、启动脚本<br style="line-height:22px"><wbr><wbr>/etc/rc.d/init.d/(启动脚本文件mysql的目录)<br style="line-height:22px"><wbr><wbr>修改登录密码<br style="line-height:22px"><wbr><wbr>MySQL默认没有密码,安装完毕增加密码的重要性是不言而喻的。<br style="line-height:22px"><wbr><wbr>1、命令<br style="line-height:22px"><wbr><wbr>usr/bin/mysqladmin<wbr>-u<wbr>root<wbr>password<wbr>'new-password'<br style="line-height:22px"><wbr><wbr>格式:mysqladmin<wbr>-u用户名<wbr>-p旧密码<wbr>password<wbr>新密码<br style="line-height:22px"><wbr><wbr>2、例子<br style="line-height:22px"><wbr><wbr>例1:给root加个密码123456。<br style="line-height:22px"><wbr><wbr>键入以下命令<wbr>:<br style="line-height:22px"><wbr><wbr>[root@test1<wbr>local]#<wbr>/usr/bin/mysqladmin<wbr>-u<wbr>root<wbr>password<wbr>123456<br style="line-height:22px"><wbr><wbr>注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。<br style="line-height:22px"><wbr><wbr>3、测试是否修改成功<br style="line-height:22px"><wbr><wbr>1)不用密码登录<br style="line-height:22px"><wbr><wbr>[root@test1<wbr>local]#<wbr>mysql<br style="line-height:22px"><wbr><wbr><wbr><br style="line-height:22px"> ERROR<wbr>1045:<wbr>Access<wbr>denied<wbr>for<wbr>user:<wbr>[email='root@localhost']'root@localhost'[/email]<wbr>(Using<wbr>password:<wbr>NO)<br style="line-height:22px"><wbr><wbr>显示错误,说明密码已经修改。<br style="line-height:22px"><wbr><wbr>2)用修改后的密码登录<br style="line-height:22px"><wbr><wbr>[root@test1<wbr>local]#<wbr>mysql<wbr>-u<wbr>root<wbr>-p<br style="line-height:22px"><wbr><wbr>Enter<wbr>password:<wbr>(输入修改后的密码123456)<br style="line-height:22px"><wbr><wbr>Welcome<wbr>to<wbr>the<wbr>MySQL<wbr>monitor.<wbr>Commands<wbr>end<wbr>with<wbr>;<wbr>or<wbr>g.<br style="line-height:22px"><wbr><wbr>Your<wbr>MySQL<wbr>connection<wbr>id<wbr>is<wbr>4<wbr>to<wbr>server<wbr>version:<wbr>4.0.16-standard<br style="line-height:22px"><wbr><wbr>Type<wbr>'help;'<wbr>or<wbr>'h'<wbr>for<wbr>help.<wbr>Type<wbr>'c'<wbr>to<wbr>clear<wbr>the<wbr>buffer.<br style="line-height:22px"><wbr><wbr>mysql&gt;<br style="line-height:22px"><wbr><wbr>成功!<br style="line-height:22px"><wbr><wbr>这是通过mysqladmin命令修改口令,也可通过修改库来更改口令。<br style="line-height:22px"><wbr><wbr>启动与停止<br style="line-height:22px"><wbr><wbr>1、启动<br style="line-height:22px"><wbr><wbr>MySQL安装完成后启动文件mysql在/etc/init.d目录下,在需要启动时运行下面命令即可。<br style="line-height:22px"><wbr><wbr>[root@test1<wbr>init.d]#<wbr>/etc/init.d/mysql<wbr>start<br style="line-height:22px"><wbr><wbr>2、停止<br style="line-height:22px"><wbr><wbr>/usr/bin/mysqladmin<wbr>-u<wbr>root<wbr>-p<wbr>shutdown<br style="line-height:22px"><wbr><wbr>3、自动启动<br style="line-height:22px"><wbr><wbr>1)察看mysql是否在自动启动列表中<br style="line-height:22px"><wbr><wbr>[root@test1<wbr>local]#<wbr>/sbin/chkconfig<wbr>–list<br style="line-height:22px"><wbr><wbr>2)把MySQL添加到你系统的启动服务组里面去<br style="line-height:22px"><wbr><wbr>[root@test1<wbr>local]#<wbr>/sbin/chkconfig<wbr>–-<wbr>add<wbr>mysql<br style="line-height:22px"><wbr><wbr>3)把MySQL从启动服务组里面删除。<br style="line-height:22px"><wbr><wbr>[root@test1<wbr>local]#<wbr>/sbin/chkconfig<wbr>–-<wbr>del<wbr>mysql<br style="line-height:22px"> 更改MySQL目录<br style="line-height:22px"><wbr><wbr>MySQL默认的数据文件存储目录为/var/lib/mysql。假如要把目录移到/home/data下需要进行下面几步:<br style="line-height:22px"><wbr><wbr>1、home目录下建立data目录<br style="line-height:22px"><wbr><wbr>cd<wbr>/home<br style="line-height:22px"><wbr><wbr>mkdir<wbr>data<br style="line-height:22px"><wbr><wbr>2、把MySQL服务进程停掉:<br style="line-height:22px"><wbr><wbr>mysqladmin<wbr>-u<wbr>root<wbr>-p<wbr>shutdown<br style="line-height:22px"><wbr><wbr>3、把/var/lib/mysql整个目录移到/home/data<br style="line-height:22px"><wbr><wbr>mv<wbr>/var/lib/mysql<wbr>/home/data/<br style="line-height:22px"><wbr><wbr>这样就把MySQL的数据文件移动到了/home/data/mysql下<br style="line-height:22px"><wbr><wbr>4、找到my.cnf配置文件<br style="line-height:22px"><wbr><wbr>如果/etc/目录下没有my.cnf配置文件,请到/usr/share/mysql/下找到*.cnf文件,拷贝其中一个到/etc/并改名为my.cnf)中。命令如下:<br style="line-height:22px"><wbr><wbr>[root@test1<wbr>mysql]#<wbr>cp<wbr>/usr/share/mysql/my-medium.cnf<wbr>/etc/my.cnf<br style="line-height:22px"><wbr><wbr>5、编辑MySQL的配置文件/etc/my.cnf<br style="line-height:22px"><wbr><wbr>为保证MySQL能够正常工作,需要指明mysql.sock文件的产生位置。<wbr>修改socket=/var/lib/mysql/mysql.sock一行中等号右边的值<br style="line-height:22px"><wbr><wbr>为:/home/mysql/mysql.sock<wbr>。操作如下:<br style="line-height:22px"><wbr><wbr>vi<wbr><wbr>my.cnf<wbr><wbr><wbr><wbr>(用vi工具编辑my.cnf文件,找到下列数据修改之)<br style="line-height:22px"><wbr><wbr>#<wbr>The<wbr>MySQL<wbr>server<br style="line-height:22px"><wbr><wbr>[mysqld]<br style="line-height:22px"><wbr><wbr>port<wbr><wbr><wbr>=<wbr>3306<br style="line-height:22px"><wbr><wbr>#socket<wbr><wbr>=<wbr>/var/lib/mysql/mysql.sock(原内容,为了更稳妥用“#”注释此行)<br style="line-height:22px"><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值