当前位置: 代码迷 >> MySQL >> mysql有关问题处理(转)
  详细解决方案

mysql有关问题处理(转)

热度:114   发布时间:2016-05-05 17:01:31.0
mysql问题处理(转)

# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
或者
# mysql -u root -p password 'newpassword'
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'


方法操作,如下:
# /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' and host='root' or host='localhost';//把空的用户密码都修改成非空的密码就行了。
mysql> FLUSH PRIVILEGES;
mysql> quit # /etc/init.d/mysqld restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>

原文链接 http://blog.csdn.net/liuyifeng_510/article/details/7045245

?

问题处理:

[trixbox1.localdomain ~]#? /etc/init.d/mysql stop
-bash: /etc/init.d/mysql: No such file or directory
[trixbox1.localdomain ~]# /etc/init.d/mysqld stop
Stopping MySQL:? [? OK? ]
[trixbox1.localdomain ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 2854
[trixbox1.localdomain ~]# Starting mysqld daemon with databases from /var/lib/mysql

[trixbox1.localdomain ~]#
[trixbox1.localdomain ~]#
[trixbox1.localdomain ~]# mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 5.0.22

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> UPDATE user SET Password=PASSWORD('passw0rd') where USER='root' and host='root' or host='localhost';
Query OK, 2 rows affected (0.02 sec)
Rows matched: 2? Changed: 2? Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[trixbox1.localdomain ~]# /etc/init.d/mysqld restart
STOPPING server from pid file /var/run/mysqld/mysqld.pid
110119 07:17:34? mysqld ended

Stopping MySQL:? [? OK? ]
Starting MySQL:? [? OK? ]
[1]+? Done??????????????????? mysqld_safe --user=mysql --skip-grant-tables --skip-networking
[trixbox1.localdomain ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.? Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.22

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+--------------------+
| Database?????????? |
+--------------------+
| information_schema |
| test?????????????? |
+--------------------+
2 rows in set (0.00 sec)

mysql> quit

?

  相关解决方案