Home > Database > Mysql Tutorial > body text

解决在Mandriva下MySQL服务错误问题

WBOY
Release: 2016-06-07 16:53:00
Original
843 people have browsed it

让我郁闷了好多天,在mandriva下默认装好的数据库mysql竟然有问题。问题是接gt;二连三的,现在说说吧。 1)安装mysql: su

  让我郁闷了好多天,在mandriva下默认装好的数据库mysql竟然有问题。问题是接>二连三的,现在说说吧。

  1)安装mysql: sudo urpmi mysql

  2)执行:mysql -uroot,出现[mysql]ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)解决:没启动mysql的守护进程,执行service mysqld start就行了

  3)继续mysql -uroot,出现ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:NO)

  解决方法:

  # /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/mysqld restart
  # mysql -uroot -p
  Enter password:
  mysql

  在解决这个问题的时候,出现了个新的问题,在做update user操作时,发现没有反映,select * from user;发现竟然为空,,本来想grant一个新的用户权限,但是却老>是不成功,最后,在user表中直接插入了一条记录,insert into user (Host,User,Password) values('localhost','root','password');注意,要把权限加进去,使这个用户可以拥有一些权限,就要置这些权限值为Y。

  好了,现在全部OK了,又可以完好的操作数据库了。分析一下mandriva装好默认数据加的原因主要在于两个:

  mysql守护进程没有启动;

  mysql的user表中没有root用户,或者说是根本没有用户,加一个具有root权限的用户即可操作了。 

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!