莫问前程 - 技术博客

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

作者:莫问前程 发布于:2013-9-17 23:56 Tuesday 分类:数据库

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 py@192.168.1.1 identified by ‘123′;
  给来自192.168.1.1的用户py分配可对数据库vtdc的employee表进行select,insert,update,delete,create,drop等操作的权限,并设定口令为123。
  mysql>grant all privileges on 51cto.* to py@192.168.1.1 identified by ‘123′;
  给来自192.168.1.1的用户py分配可对数据库51cto所有表进行所有操作的权限,并设定口令为123。
  mysql>grant all privileges on *.* to py@192.168.1.1 identified by ‘123′;
  给来自192.168.1.1的用户py分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。
  mysql>grant all privileges on *.* to joe@localhost identified by ‘123′;
  给本机用户joe分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。

标签: MYSQL

评论(0) 引用(86) 浏览(25046)

centos-yum update问题

作者:莫问前程 发布于:2013-9-17 23:55 Tuesday 分类:Linux

刚安装完的centos 6.2系统发现yum仓库更新不了。提示报错信息:

[root@hbase01-222 ~]# yum update

Loaded plugins: aliases, changelog,downloadonly, fastestmirror, kabi, presto, security, tmprepo, verify,versionlock

Loading support for CentOS kernel ABI

Determining fastest mirrors

Could not retrieve mirrorlisthttp://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was

14: PYCURL ERROR 6 - "Couldn't resolvehost 'mirrorlist.centos.org'"

Could not retrieve mirrorlisthttp://mirrorlist.centos.org/?release=6&arch=x86_64&repo=extras errorwas

14: PYCURL ERROR 6 - "Couldn't resolvehost 'mirrorlist.centos.org'"

Could not retrieve mirrorlisthttp://mirrorlist.centos.org/?release=6&arch=x86_64&repo=updates errorwas

14: PYCURL ERROR 6 - "Couldn't resolvehost 'mirrorlist.centos.org'"

http://mirrors.163.com/centos/6.2/os/x86_64/repodata/repomd.xml:[Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'mirrors.163.com'"

Trying other mirror.

Error: Cannot retrieve repository metadata(repomd.xml) for repository: base. Please verify its path and try again

[root@hbase01-222 ~]# service iptables stop

[root@hbase01-222 ~]# nslookup  mirrorlist.centos.org

;; connection timed out; no servers couldbe reached

到这里发现问题了,我的域名解析不了,yum的配置文件里指向的域名就识别不了了。重新设置下dns指向。

[root@hbase01-222 ~]# vim /etc/resolv.conf

# Generated by NetworkManager

search 38forsbm

nameserver 8.8.8.8

[root@hbase01-222 ~]# yum update –y   --更新可以使用。

标签: LINUX

评论(0) 引用(92) 浏览(26116)

Powered by 木匠 鲁ICP备88888888号