linux下如何安装新版的mysql

2014 年 5 月 7 日4700

linux下如何安装新版的mysql

发布者:chinaitlab

 日期:

2014-04-28 13:53:30 浏览次数:0 (共有_条评论)

查看评论 | 我要评论

  安装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将给予提示并停止卸载。你可以使用如下的命令来忽略依赖关系,直接开始卸载:

  rpm -e [package name] --nodeps

  直到如下命令没有任何结果输出为止

  #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%]

  ……

  A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !

  You will find that password in '/root/.mysql_secret'.

  You must change that password on your first connect,

  no other statement but 'SET PASSWORD' will be accepted.

  See the manual for the semantics of the 'password expired' flag.

  ……

  [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)

  注:如果没有安装mysql client,就不会有mysql,mysqladmin等命令。

  或者用如下命令登录mysql:

  #mysql -u root -p

  Enter password: (输入密码)

  其中-u后跟的是用户名,-p要求输入密码,回车后在输入密码处输入密码。

  注意:这个mysql文件在/usr/bin目录下,与后面讲的启动文件/etc/init.d/mysql不是一个文件。

  在安装mysql5.6的时候,安装包随机给root用户生成了一个密码,该密码在'/root/mysql_secret'文件里。

  当使用mysql -u root -p [password]登录后,需要使用如下命令更改密码:

  mysql> SET PASSWORD=PASSWORD('123456');

  如果不执行set password,就执行其他命令,就会碰到如下错误:

  ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

  7.生成my.cnf文件

  默认情况下mysql是不会生成my.cnf文件的,但可以进入到/usr/share/mysql/目录找一个cnf文件生成my.cnf文件,如下:

  cp /usr/share/mysql/my-huge.cnf /etc/my.cnf

  然后编辑my.cnf,按照需要修改或添加相应参数。

>>更多交流,请到ChinaUnix【Linux系统管理论坛】:http://http://www.zjjv.com///bbs/forum-2-1.html

关键词:

相关文章

网友评论

已有0位网友发表了看法

0 0