安装linux的时候,若选择了mysql,安装系统的时候会自动安装mysql,若想安装新版本的mysql,如要将之前的安装的删除掉.下面介绍如何删除之前的mysql重新安装新版本的mysql.1.找到之前安装mysql#rpm -qa grep -i mysql
php-mysql-5.1.6-5.el5
MySQL-python-1.2.1-1
mysql-bench-5.0.22-2.1
mysql-5.0.22-2.1
mysql-server-5.0.22-2.1
mysql-connector-odbc-3.51.12-2.2
mod_auth_mysql-3.0.0-3.1
mysql-devel-5.0.22-2.1
qt-MySQL-3.3.6-20.el5
perl-DBD-MySQL-3.0007-1.fc6
2.将以上的安装包逐个删除掉,将依赖的包也相应的删除掉
rpm -e php-mysql-5.1.6-5.el5
rpm -e MySQL-python-1.2.1-1
rpm -e mysql-bench-5.0.22-2.1
rpm -e mysql-5.0.22-2.1
rpm -e mysql-server-5.0.22-2.1
rpm -e mysql-connector-odbc-3.51.12-2.2
rpm -e mod_auth_mysql-3.0.0-3.1
rpm -e mysql-devel-5.0.22-2.1
rpm -e qt-MySQL-3.3.6-20.el5
rpm -e perl-DBD-MySQL-3.0007-1.fc6
直到如下命令没有任何结果输出为止
#rpm -qa grep -i mysql
3.安装新版本的mysql
[root@hxl ftp]# rpm -ivh MySQL-server-5.5.29-2.rhel5.i386.rpm
Preparing... ########################################### [100%]
ls: /var/lib/mysql/*.err: No such file or directory
ls: /var/lib/mysql/*.err: No such file or directory
1:MySQL-server ########################################### [100%]
[root@hxl ftp]# rpm -ivh MySQL-client-5.5.29-2.rhel5.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
4.安装完成以后启动mysql
[root@hxl subsys]# service mysql start
Starting MySQL...The server quit without updating PID file [FAILED]b/mysql/hxl.pid).
发现数据库无法启动,查看错误日志/var/lib/mysql/hxl.err,发现错误如下:
130130 22:30:32 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
解决办法执行如下命令
#mysql_install_db --user=mysql
5.启动数据库
[root@hxl mysql]# service mysql start
Starting MySQL.... [ OK ]
6.登录数据库
[root@hxl mysql]# mysql -h hxl -uroot
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.5.29 MySQL Community Server (GPL)
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql>
mysql>
mysql>
mysql> select version();
+-----------+
version()
+-----------+
5.5.29
+-----------+
1 row in set (0.00 sec)
7.生成my.cnf文件
默认情况下mysql是不会生成my.cnf文件的,但可以进入到/usr/share/mysql/目录找一个cnf文件生成my.cnf文件,如下:
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf
然后编辑my.cnf,按照需要修改或添加相应参数.
-- The End --
本文转自http://blog.chinaunix.net