首页 电脑 电脑学堂 查看内容

常见mysql的错误以及解决方法

2011-5-3 10:53 869 0

摘要:   MYSQL启动错误  Can't open the mysql.plugin table...2009-06-01 00:52Can't open the mysql.plugin table. ...
关键词: nbsp MYSQL 权限 local shell usr PRIVILEGES 数据库 Password mysqld

  MYSQL启动错误  Can't open the mysql.plugin table...2009-06-01 00:52Can't open the mysql.plugin table. Please run mysql_upgrade to create it.  mysql是已经被编译好的mysql-5.1.28-rc-linux-i686-glibc23.tar.gz  shell>mkdir /usr/local/mysql  shell> groupadd mysql  shell> useradd -g mysql mysql  shell> tar zxf /path/to/mysql-VERSION-OS.tar.gz  shell> cp -r * full-path-to-mysql-VERSION-OS/* /usr/local/mysql/  shell> cd /usr/local/mysql  shell> chown -R mysql .  shell> chgrp -R mysql .  shell> scripts/mysql_install_db --user=mysql  shell> chown -R root .  shell> chown -R mysql data  shell> bin/mysqld_safe --user=mysql &  这是执行scripts/mysql_install_db --user=mysql没有成功的原因,没有一个初始化数据库,不能启动mysql守护进程,重新执行:  shell> scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/date --user=mysql  由于安装方法不同mysql的安装目录也不相同,mysql_install_db文件的位置也不一样  可以使用find / -name mysql_install_db来查找  实例:  /usr/local/mysql/bin/mysql_install_db --user=mysql --datadir=/usr/local/mysql  --basedir=/usr/local/mysql  --------------------------------------------------------------------------------  在MYSQL启动老失败即:Starting MySQL.Manager of pid-file quit without updating file.[FAILED]  查看错误日志显示:mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data  /usr/local/mysql/bin/mysqld: Table 'mysql.plugin' doesn't exist  Can't open the mysql.plugin table. Please run mysql_upgrade to create it.  InnoDB: The first specified data file ./ibdata1 did not exist:  [root@centos var]# service mysqld stop  MySQL manager or server PID file could not be found!       [FAILED]  解决办法:  首先查看一下进程  [root@centos mysql]# ps aux |grep mysq*  root      2643  0.0  0.2   4536  1224 ?        S    01:09   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/var --pid-file=/usr/local/mysql/var/centos.pid  mysql     2757  0.0  1.2  36976  6608 ?        Sl   01:09   0:00 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --user=mysql --log-error=/usr/local/mysql/var/centos.err --pid-file=/usr/local/mysql/var/centos.pid --socket=/tmp/mysql.sock --port=3306  root      4788  0.0  0.1   3920   684 pts/2    R+   11:11   0:00 grep mysq*  如果看到上面的内容,那说明,Mysql的进程卡死了,这时用就要把这些卡死的进程都关闭  [root@centos mysql]# kill 2643  [root@centos mysql]# kill 2757  启动Mysql 就ok了  [root@centos mysql]# service mysqld start  Starting MySQL.                                            [  OK  ]  --------------------------------------------------------------------------------  mysql数据库忘记密码  现在终于被我找到了解决方法,如下(请先测试方法三,谢谢!):  方法一:  # /etc/init.d/mysql stop  # mysqld_safe --user=mysql --skip-grant-tables --skip-networking &  # mysql -u root mysql  mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';  mysql> FLUSH PRIVILEGES;  mysql> quit  # /etc/init.d/mysql restart  # mysql -uroot -p  Enter password: <输入新设的密码newpassword>  方法二:  直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码:  # mysql -udebian-sys-maint -p  Enter password: <输入[client]节的密码>  mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';  mysql> FLUSH PRIVILEGES;  mysql> quit  # mysql -uroot -p  Enter password: <输入新设的密码newpassword>  mysql>  --------------------------------------------------------------------------------  遇到了 SQLException: access denied for  @'localhost' (using password: no)  解决办法   grant all privileges on *.* to py@localhost identified by '1';  flush privileges;  拿  py    1 登陆  附:  mysql> grant 权限1,权限2,…权限n on 数据库名称.表名称 to 用户名@用户地址 identified by ‘连接口令’;  权限1,权限2,…权限n代表select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等14个权限。  当权限1,权限2,…权限n被all privileges或者all代替,表示赋予用户全部权限。  当数据库名称.表名称被*.*代替,表示赋予用户操作服务器上所有数据库所有表的权限。  用户地址可以是localhost,也可以是ip地址、机器名字、域名。也可以用’%'表示从任何地址连接。  ‘连接口令’不能为空,否则创建失败。  mysql>grant select,insert,update,delete,create,drop on vtdc.employee to [email protected] identified by ‘123′;  给来自192.168.1.1的用户py分配可对数据库vtdc的employee表进行select,insert,update,delete,create,drop等操作的权限,并设定口令为123。  mysql>grant all privileges on 51cto.* to [email protected] identified by ‘123′;  给来自192.168.1.1的用户py分配可对数据库51cto所有表进行所有操作的权限,并设定口令为123。  mysql>grant all privileges on *.* to [email protected] identified by ‘123′;  给来自192.168.1.1的用户py分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。  mysql>grant all privileges on *.* to joe@localhost identified by ‘123′;  给本机用户joe分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除

路过

雷人

握手

鲜花

鸡蛋

最新评论

返回顶部