手机版
你好,游客 登录 注册
背景:
阅读新闻

Linux 下rpm安装后的目录结构和一些配置

[日期:2013-06-10] 来源:Linux社区  作者:Linux [字体: ]

1、准备安装程序(官方网站下载)

服务端:MySQL-server-community-5.1.44-1.rhel4.i386.rpm

客户端:MySQL-client-community-5.1.44-1.rhel4.i386.rpm

2、安装(打印信息略)

[root@localhost /]#rpm -ivh MySQL-server-community-5.1.44-1.rhel4.i386.rpm;

[root@localhost /]#rpm -ivh MySQL-client-community-5.1.44-1.rhel4.i386.rpm;

3、查看安装是否成功

[root@localhost /]#netstat -ntpl;

显示3306端口开放表示服务安装成功

4、测试连接

(*修改root密码)

[root@localhost /]#/usr/bin/mysqladmin -u root password 'xxxxxx';

[root@localhost /]#mysql -u root -p

Enter password:xxxxxx

出现mysql>表示登陆成功!

5、对mysql用户设置远程访问权限

方法1、改表法:登陆mysql后,更改“mysql”数据库里的“user”表里的“host”项,将“localhost”改“%”

mysql>use mysql;

mysql>update user set host ='%' where user ='root';

mysql>select host,user from user;

mysql>FLUSH PRIVILEGES

方法2、授权法:假设允许用户username通过密码password从远程连接到mysql服务器

mysql>GRANT ALL RRIVILEGES ON *.* TO username@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

mysql>FLUSH PRIVILEGES;

6、安装目录结构

数据库目录:/var/lib/mysql/

配置文件:/usr/share/mysql(mysql.server命令及配置文件)

相关命令:/usr/bin(mysqladmin、mysqldump等命令)(*mysql的一种安全启动方式:/usr/bin/mysqld_safe  --user=root &)

启动脚本:/etc/rc.d/init.d/

7、停止/启动mysql服务

[root@localhost /]#service mysql stop;

[root@localhost /]#service mysql start;

8、修改字符编码

查看字符编码:

[root@localhost /]#show variables like 'character\_set\_%';

[root@localhost /]#show variables like 'collation_%';

停止mysql服务

将目录/usr/share/mysql下的文件my-medium.cnf拷贝到/etc/下并改名为my.cnf

打开my.cnf在[client]和[mysqld]下面均加上default-character-set=utf8,并保存

*mysql5.5 改了字符集设置参数 character-set-server=utf8

重启mysql服务

9、卸载mysql

[root@localhost /]#rpm -qa|grep -i mysql

显示:

MySQL-server-community-5.1.44-1.rhel4.i386.rpm

MySQL-client-community-5.1.44-1.rhel4.i386.rpm

[root@localhost /]#rpm -e  MySQL-server-community-5.1.44-1.rhel4.i386.rpm

[root@localhost /]#rpm -e MySQL-client-community-5.1.44-1.rhel4.i386.rpm

删除残余文件

[root@localhost /]#rm -f /etc/my.cnf

[root@localhost /]#rm -f /var/lib/mysql

10、复制mysql数据库

源数据库名:source_db  用户名:root 密码:xxxxxx

目标数据库名:target_db  用户名:root 密码:xxxxxx 所在主机:221.218.9.41

shell>mysqldump source_db -uroot -pxxxxxx --opt | mysql target_db -uroot -pxxxxxx -h 221.218.9.41

linux
相关资讯       rpm安装 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款