[Root @ dbsvr01 E] # mysql-uroot-P
Enter password:
Error 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: Yes)
[Root @ dbsvr01 E] #
======================================
Delete the value of user. User is null, or update null to 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
Don't forget the last &
[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-
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,201 3, 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. 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,201 3, 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:33060.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 ~] #
In Linux, you can use the MySQL command to log on to the MySQL server. If you need to execute the shell command, such as viewing the file list in a directory, you do not need to exit the mysql client, enter system or \ at the MySQL prompt \! Add the system command.
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. 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:33060.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>
I think the root connection is local, so the previous address is 0.0.0.0. If another computer is connected over TCP, there should be an IP address.
Mysql>\! PS-Ef | grep MySQL
Root
4241 1 0 00:00:00 pts/1/bin/sh/usr/bin/mysqld_safe
-- Datadir =/var/lib/MySQL -- socket =/var/lib/MySQL. Sock
-- PID-file =/var/run/mysqld. PID -- basedir =/usr-
MySQL
4343 4241 0 00:00:00 pts/1/usr/libexec/mysqld -- basedir =/usr
-- Datadir =/var/lib/MySQL -- user = MySQL -- log-error =/var/log/mysqld. Log
-- PID-file =/var/run/mysqld. PID
Root 4391 4014 0 00:00:00 pts/1 mysql-uroot-P
Root 4436 4391 0 00:00:00 pts/1 sh-c ps-Ef | grep MySQL
Root 4438 4436 0 00:00:00 pts/1 grep MySQL
Mysql>\! PS-Ef | grep MySQL | grep-V grep
Root
4241 1 0 00:00:00 pts/1/bin/sh/usr/bin/mysqld_safe
-- Datadir =/var/lib/MySQL -- socket =/var/lib/MySQL. Sock
-- PID-file =/var/run/mysqld. PID -- basedir =/usr-
MySQL
4343 4241 0 00:00:00 pts/1/usr/libexec/mysqld -- basedir =/usr
-- Datadir =/var/lib/MySQL -- user = MySQL -- log-error =/var/log/mysqld. Log
-- PID-file =/var/run/mysqld. PID
Root 4391 4014 0 00:00:00 pts/1 mysql-uroot-P
Mysql>