centos 安装mysql操作手册

e20714038 贡献于2014-03-14

作者 wu  创建于2012-06-06 01:30:00   修改者wu  修改于2014-03-14 02:54:00字数5416

文档摘要:在大多数情况下,你只需要安装MySQL-server和MySQL-client得到一个功能MySQL软件包安装。另一个包是不需要一个标准的安装。如果你想开办一个MySQL-Max服务器,有更多的能力,你也应该安装MySQL-Max每分钟转速。但是,你应该这样做的只是在安装MySQL-server每分钟转速。
关键词:

======================================= * 安装环境说明 (1) MySQL5.6 性能好,并且稳定. (2) CentOS 64位 ======================================= 1. mysql各个组件的说明 In most cases, you only need to install the MySQL-server and MySQL-client packages to get a functional MySQL installation. The other packages are not required for a standard installation. If you want to run a MySQL-Max server that has additional capabilities, you should also install the MySQL-Max RPM. However, you should do so only after installing the MySQL-server RPM. If you get a dependency failure when trying to install the MySQL 4.0 packages (for example, ``error: removing these packages would break dependencies: libmysqlclient.so.10 is needed by ...''), you should also install the package MySQL-shared-compat, which includes both the shared libraries for backward compatibility (libmysqlclient.so.12 for MySQL 4.0 and libmysqlclient.so.10 for MySQL 3.23). The following RPM packages are available: MySQL-server-VERSION.i386.rpm The MySQL server. You will need this unless you only want to connect to a MySQL server running on another machine. Note: Server RPM files were called MySQL-VERSION.i386.rpm before MySQL 4.0.10. That is, they did not have -server in the name. MySQL-Max-VERSION.i386.rpm The MySQL-Max server. This server has additional capabilities that the one provided in the MySQL-server RPM does not. You must install the MySQL-server RPM first, because the MySQL-Max RPM depends on it. MySQL-client-VERSION.i386.rpm The standard MySQL client programs. You probably always want to install this package. MySQL-bench-VERSION.i386.rpm Tests and benchmarks. Requires Perl and the DBD::mysql module. MySQL-devel-VERSION.i386.rpm The libraries and include files that are needed if you want to compile other MySQL clients, such as the Perl modules. MySQL-shared-VERSION.i386.rpm This package contains the shared libraries (libmysqlclient.so*) that certain languages and applications need to dynamically load and use MySQL. MySQL-shared-compat-VERSION.i386.rpm This package includes the shared libraries for both MySQL 3.23 and MySQL 4.0. Install this package instead of MySQL-shared if you have applications installed that are dynamically linked against MySQL 3.23 but you want to upgrade to MySQL 4.0 without breaking the library dependencies. This package has been available since MySQL 4.0.13. MySQL-embedded-VERSION.i386.rpm The embedded MySQL server library (from MySQL 4.0). MySQL-VERSION.src.rpm This contains the source code for all of the previous packages. It can also be used to rebuild the RPMs on other architectures (for example, Alpha or SPARC). 在大多数情况下,你只需要安装MySQL-server和MySQL-client得到一个功能MySQL软件包安装。另一个包是不需要一个标准的安装。如果你想开办一个MySQL-Max服务器,有更多的能力,你也应该安装MySQL-Max每分钟转速。但是,你应该这样做的只是在安装MySQL-server每分钟转速。 如果你得到一个依赖的失败尝试安装MySQL 4.0软件(例如,“错误:移除这些包裹将打破依赖性:libmysqlclient.so。10需要……”),那么你也应该安装包,它包括MySQL-shared-compat共享库(libmysqlclient.so向后兼容性。12 libmysqlclient.so MySQL 4.0。10 MySQL 3.23)。 下面的RPM格式的软件包可供选择: (1)MySQL-server-VERSION.i386。 rpm的MySQL服务器。你需要这样,除非你只是想连接到一个MySQL服务器运行在另一台机器上。注意:服务器文件被称为MySQL-VERSION.i386转速。前4.0.10转0。也就是说,他们没有-服务器名称。 (2) MySQL-Max-VERSION.i386。 MySQL-Max rpm的服务器。这个服务器有额外的能力,这一规定不MySQL-server转速。你必须安装MySQL-server RPM第一,因为MySQL-Max RPM取决于它。 (3) MySQL-client-VERSION.i386。 标准的MySQL客户转程序。你可能永远要安装这个包裹。 (4) MySQL-bench-VERSION.i386。 每分钟转速测试和基准。需要Perl和差的:mysql模块。 (5) MySQL-devel-VERSION.i386。 rpm图书馆和包含文件,如果你想编写需要其他MySQL的客户,如Perl模块。 (6) MySQL-shared-VERSION.i386。 这个包包含了rpm共享库(libmysqlclient.so *),某些语言和应用程序需要动态装载和使用MySQL。 (7) MySQL-shared-compat-VERSION.i386。 这个包包括了rpm共享库都3.23和MySQL MySQL 4.0。安装这个包裹,而不是MySQL-shared如果你安装应用动态链接攻击,但你需要MySQL 3.23升级到MySQL 4.0没有打破这个图书馆的附庸。这个包裹已经问世以来4.0.13 MySQL的。 (8) MySQL-embedded-VERSION.i386。 rpm嵌入式MySQL服务器库(从MySQL 4.0)。 MySQL-VERSION.src。这包含转速的源码,所有以前的包装。它也可以被用来重建的rpm软件将在其他体系结构(例如,阿尔法或SPARC)。 2. 安装文件 rpm -ivh MySQL-server-5.6.13-1.linux_glibc2.5.x86_64.rpm rpm -ivh MySQL-client-5.6.13-1.linux_glibc2.5.x86_64.rpm rpm -ivh MySQL-devel-5.6.13-1.linux_glibc2.5.x86_64.rpm rpm -ivh MySQL-shared-5.6.13-1.linux_glibc2.5.x86_64.rpm rpm -ivh MySQL-shared-compat-5.6.13-1.linux_glibc2.5.x86_64.rpm 3、查看安装是否成功 先启动服务 service mysql start [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 删除失败时 强制删除 rpm -e --nodeps mysql  // 强力删除模式,如果使用上面命令删除时,提示有 删除残余文件 [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

下载文档到电脑,查找使用更方便

文档的实际排版效果,会与网站的显示效果略有不同!!

需要 3 金币 [ 分享文档获得金币 ] 0 人已下载

下载文档