Heim  >  Artikel  >  Datenbank  >  CentOS下MySQL卸载和安装

CentOS下MySQL卸载和安装

WBOY
WBOYOriginal
2016-06-07 17:13:191174Durchsuche

MySQL的分区表功能自5.1才开始支持,Centos的MySQL为5.0的,需要将其卸载后安装5.1

MySQL的分区表功能自5.1才开始支持,CentOS的MySQL为5.0的,需要将其卸载后安装5.1

下面是一些操作、错误和解决方案的记录:

1.关闭目前的mysql服务

    /etc/init.d/mysqld stop

2.确保已正常关闭

   ps -ef | grep mysql

   如果没关闭,kill之

3. 查询mysql的安装情况:

    rpm -qa | grep mysql

    将列出来的删除。

    rpm -e mysql-server.x86_64

    如果报有多个,则用项 --allmatches将其全部删掉

4. 下载mysql5.5的rpm版

    rpm -ivh mysql-server和client

5. 启动新的mysql

    /etc/init.d/mysql start

6. 尝试访问

   mysql -uroot -p

  我的 默认无密码,可正常访问

7.但是之前的php应用没法用了,报cannot load mysql extension .please check your php configuration

  原因是刚才把php-mysql删了,其实是不应该删的。

8.重新安装php-mysql,我的系统为centos5.3,php为5.1.依赖的php-mysql也为5.1.yum安装php-mysql报:

libmysqlclient.so.15()(64bit) is needed 

libmysqlclient.so.15(libmysqlclient_15)(64bit) is needed 

php-common is needed

libmysqlclient.so是包含在mysql-share的,但直接安装5.5版的mysql-share是不行的,因为该版本的没有libmysqlclient.so.15,都高于15.

需要到#downloads下载(MySQL-shared-compat-5.1.62-1.rhel5.i386.rpm)

然后安装,但因为我支持装了5.5的mysql-share,会报冲突,即rpm安装时无法覆盖之前的,使用项--force强制覆盖即可。

rpm -ivh php-common-VERSION php-mysql-VERSION安装成功, 解决该问题


9.在为其他节点远程访问该服务器的数据库设置时出错,Access denied for user 'root'@'localhost'。解决方案见:

,即:

MySQL节点执行GRANT命令为SPIDER服务器进行授权时,,发生了如下错误: 

mysql> GRANT ALL ON *.* TO 'spider'@'spiderdb' IDENTIFIED BY 'spider'; 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)


可是我就是使用root用户登录的,root的password也是空的,怎么可能会发生这个错误呢。 

网上有相同的错误,是登录不进MySQL的解决办法。如果是忘记了密码,可以用下边的方法: 

# /etc/init.d/mysql stop 
# mysqld_safe -u mysql --skip-grant-tables --skip-networking & 
# mysql -u mysql 
mysql> UPDATE user SET Password=PASSWORD('newpassword')where USER='root'; 
mysql> FLUSH PRIVILEGES; 
mysql> exit 
# /etc/init.d/mysqld restart 
# mysql -uroot -pnewpassword 


可是这个方法却解决不了我的问题。 

网上还有一种办法,删除user.user中值为NULL的(delete from user where user is NULL),或更新NULL为test(update user set user=‘test‘ where user is NULL)。但是也不好使。 

偶然发现对于单个DB的授权是没有问题的,难道是root没有特定DB的权限?写了个script对于每个database执行"GRANT ALL ON $DATABASE.* TO 'root'@'localhost' IDENTIFIED BY 'cps-pt' with grant option;",居然是information_schema的时候出错了。 

前两天同志执行dump/restore的时候,DB曾经死掉过,难道information_schema被破坏掉了。 
这好像是MySQL的一个restore时的bug。 

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