Heim  >  Artikel  >  Datenbank  >  RHEL下安装MySQL

RHEL下安装MySQL

WBOY
WBOYOriginal
2016-06-07 16:52:51985Durchsuche

1.到mysql的网站(必须到官方网站下载,防止数据被修改,纂改过)下载四个必须rpm 安装包:http://dev.mysql.com/downloads/mysql/5.0

1.到mysql的网站(必须到官方网站下载,防止数据被修改,纂改过)下载四个必须rpm 安装包:
#linux-rhel5-ia64-rpms

MySQL-client-5.1.16-0.glibc23.i386.rpm
MySQL-devel-5.1.16-0.glibc23.i386.rpm
MySQL-server-5.1.16-0.glibc23.i386.rpm
MySQL-shared-5.1.16-0.glibc23.i386.rpm

2. 通过ssh远程控制工具传到服务器上,放在适当的目录下(如:/opt/mysql/mysql5.1.16)
3.进入目录(/opt/mysql/mysql5.1.16)下安装msyql:
rpm 文件是Red Hat公司开发的软件安装包,rpm可让Linux在安装软件包时免除许多复杂的手续。该命令在安装时常用的参数是 –ivh ,其中i表示将安装指定的rmp软件包,V表示安装时的详细信息,h表示在安装期间出现"#"符号来显示目前的安装过程。这个符号将持续到安装完成后才停止。

[root@qudee mysql5.1.16]# rpm –ivh MySQL-client-5.1.16-0.glibc23.i386.rpm
[root@qudee mysql5.1.16]# rpm –ivh MySQL-devel-5.1.16-0.glibc23.i386.rpm
[root@qudee mysql5.1.16]# rpm –ivh MySQL-shared-5.1.16-0.glibc23.i386.rpm
[root@qudee mysql5.1.16]# rpm –ivh MySQL-server-5.1.16-0.glibc23.i386.rpm

 显示如下信息

warning: MySQL-server-5.1.16-0.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost password 'new-password'
See the manual for more instructions.

NOTE: If you are upgrading from a MySQL the /usr/bin/mysql_fix_privilege_tables. Otherwise you will not be
able to use the new GRANT command!

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at

Support MySQL by buying support/licenses athttps://order.mysql.com
Starting MySQL...................................[失败]

4.查看已安装的包
[root@qudee mysql5.1.20]# rpm -qa | grep -i mysql
或者 [root@qudee mysql5.1.20]# rpm -qa | grep mysql

MySQL-devel-5.1.20-0.glibc23
MySQL-shared-5.1.20-0.glibc23
MySQL-client-5.1.20-0.glibc23
MySQL-server-5.1.20-0.glibc23

5.查看[root@qudee /]# locate mysql.server 的路径
/usr/share/man/man1/mysql.server.1.gz
/usr/share/mysql/mysql.server
复制并更名 [root@qudee /]#cp /usr/share/mysql/mysql.server /etc/init.d/mysqld
6.查看[root@qudee /]# locate my-huge.cnf 的路径
/usr/share/doc/MySQL-server-5.1.16/my-huge.cnf
/usr/share/mysql/my-huge.cnf
复制并更名[root@qudee /]#cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
7.启动服务:
service mysqld start
Starting MySQL [ OK ]
启动成功!恭喜~~~
8.编辑vi /etc/my.cnf 这个文件,设置字符集,支持国际化.

default-character-set=utf8 //在此添加字符集
# Here follows entries for some specific programs

# The MySQL server
[mysqld] port = 3306
#socket = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 384M
max_allowed_packet = 1M
table_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M


default-character-set=utf8 //在此添加字符集
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 16

先按Esc, 再同时按Shift + ; 再输入wq! (推出并保存)
呵呵! 字符集就配置好了~~~
9.MySQL默认的数据文件存储目录为/var/lib/mysql。假如要把目录移到/qudeedata/dbdata/mysql5.1.16下需要进行下面几步:
(1)、/qudeedata/dbdata目录下建立mysql5.1.16目录
cd /qudeedata/dbdata
mkdir mysql5.1.16
(2)、把MySQL服务进程停掉:
service mysqld stop
(3)、把/var/lib/mysql整个目录移到/qudeedata/dbdata/mysql5.1.16
mv /var/lib/mysql /qudeedata/dbdata/mysql5.1.16
这样就把MySQL的数据文件移动到了/qudeedata/dbdata/mysql5.1.16 下
(4)、编辑MySQL的配置文件/etc/my.cnf
为保证MySQL能够正常工作,需要指明mysql.sock文件的产生位置。修改socket=/var/lib/mysql/mysql.sock一行中等号右边的值为:
/qudeedata/dbdata/mysql5.1.16/mysql/mysql.sock 。操作如下:
命令: vi  my.cnf    (用vi工具编辑my.cnf文件,找到下列数据修改之)
# The MySQL server
[mysqld]
port   = 3306
#socket  = /var/lib/mysql/mysql.sock(原内容,为了更稳妥用"#"注释此行)
socket  = /qudeedata/dbdata/mysql5.1.16/mysql/mysql.sock   (加上此行)
(5)、修改MySQL启动脚本/etc/rc.d/init.d/mysqld
最后,需要修改MySQL启动脚本/etc/rc.d/init.d/mysqld,把其中datadir=/var/lib/mysql一行中,,等号右边的路径改成你现在的实际存放路径:
/qudeedata/dbdata/mysql5.1.16。
[root@test1 etc]# vi /etc/rc.d/init.d/mysqld
#datadir=/var/lib/mysql    (注释此行)
datadir=/qudeedata/dbdata/mysql5.1.16   (加上此行)
10、自动启动
1)察看mysql是否在自动启动列表中
[root@qudee /]# chkconfig –list
2)把MySQL添加到你系统的启动服务组里面去
[root@qudee /]# chkconfig – add mysql
11.测试通过命令是否能够启动,停止,重启
结果:

[root@qudee /]# service mysqld start
Starting MySQL [ OK ]
[root@qudee /]# service mysqld restart
Shutting down MySQL.. [ OK ]
Starting MySQL [ OK ]
[root@qudee /]# service mysqld stop
Shutting down MySQL... [ OK ]
[root@qudee /]# /etc/init.d/mysqld start
Starting MySQL [ OK ]
[root@qudee /]# /etc/init.d/mysqld restart
Shutting down MySQL... [ OK ]
Starting MySQL [ OK ]
[root@qudee /]# /etc/init.d/mysqld stop
Shutting down MySQL.. [ OK ]

证明,成功安装mysql.注:还可以通过添加,查询,删除数据库中的数据进行操作.
12.完成安装!

linux

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn