mysql ERROR 1045(28000)

[root@DBSVR01 e]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@DBSVR01 e]#

=======================

删除user.user中值为NULL的,或更新NULL为test 1)delete from user where user is NULL 2)update user set user=‘test‘ where user is NULL

=======================1

[root@DBSVR01 bin]# /etc/init.d/mysqld stop
Stopping mysqld:                                           [  OK  ]
[root@DBSVR01 bin]#

=======================2

别忘了最后的 &

[root@DBSVR01 ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 4040
[root@DBSVR01 ~]# 130430 20:34:23 mysqld_safe Logging to '/var/log/mysqld.log'.
130430 20:34:23 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
^C
[root@DBSVR01 ~]#

=======================3
[root@DBSVR01 ~]# 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 2
Server version: 5.1.69 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> update user set password=password('root') where user='root' and host='root' or host='localhost';
Query OK, 2 rows affected (0.01 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[root@DBSVR01 ~]# /etc/init.d/mysqld restart
130430 20:55:10 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
[1]+  Done                    mysqld_safe --user=mysql --skip-grant-tables --skip-networking

[root@DBSVR01 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.69 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

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

mysql>quit

Bye

[root@DBSVR01 ~]# netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 0.0.0.0:53377               0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      
tcp        0    196 168.168.80.8:22             168.168.80.1:17105          ESTABLISHED
tcp        0      0 :::111                      :::*                        LISTEN      
tcp        0      0 :::44691                    :::*                        LISTEN      
tcp        0      0 :::22                       :::*                        LISTEN      
tcp        0      0 ::1:631                     :::*                        LISTEN      
[root@DBSVR01 ~]#  

在linux下可以用mysql命令登陆连接到mysql服务器,如果这时需要执行shell命令,例如查看某个目录下的文件列表,其实不需要退出mysql客户端,只需要在mysql提示符下输入system或\! 再加上系统命令即可

mysql> status
--------------
mysql  Ver 14.14 Distrib 5.1.69, for redhat-linux-gnu (i386) using readline 5.1

Connection id:        3
Current database:    
Current user:        root@localhost
SSL:            Not in use
Current pager:        stdout
Using outfile:        ''
Using delimiter:    ;
Server version:        5.1.69 Source distribution
Protocol version:    10
Connection:        Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
UNIX socket:        /var/lib/mysql/mysql.sock
Uptime:            8 min 53 sec

Threads: 1  Questions: 41  Slow queries: 0  Opens: 30  Flush tables: 1  Open tables: 23  Queries per second avg: 0.76
--------------

mysql>  

mysql> system netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 0.0.0.0:53377               0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      
tcp        0     52 168.168.80.8:22             168.168.80.1:17105          ESTABLISHED
tcp        0      0 :::111                      :::*                        LISTEN      
tcp        0      0 :::44691                    :::*                        LISTEN      
tcp        0      0 :::22                       :::*                        LISTEN      
tcp        0      0 ::1:631                     :::*                        LISTEN      
mysql>

我想应该是root在本地连接的原因,所以前面的地址是0.0.0.0,如果在另外的电脑上,通过TCP连过来,就应该有IP地址了。

mysql> \! ps -ef | grep mysql
root      4241     1  0 20:55 pts/1    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr -
mysql     4343  4241  0 20:55 pts/1    00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid
root      4391  4014  0 21:03 pts/1    00:00:00 mysql -uroot -p
root      4436  4391  0 21:22 pts/1    00:00:00 sh -c  ps -ef | grep mysql
root      4438  4436  0 21:22 pts/1    00:00:00 grep mysql
mysql> \! ps -ef | grep mysql | grep -v grep
root      4241     1  0 20:55 pts/1    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr -
mysql     4343  4241  0 20:55 pts/1    00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid
root      4391  4014  0 21:03 pts/1    00:00:00 mysql -uroot -p
mysql> 

 

 

 

 

 

posted on 2013-05-01 00:14  simhare  阅读(287)  评论(0编辑  收藏  举报

导航