【整理】原始碼安裝mysql-5.6.10

摩雲飛發表於2016-05-11
       參考別人的經驗,加上自己的理解,完成下面的動作。

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


【原始碼安裝 mysql-5.6.10】

(1)解壓 mysql 原始碼 

1
2
[root@Betty Me_wget]# tar zxvf mysql-5.6.10.tar.gz
[root@Betty Me_wget]# cd mysql-5.6.10


(2)建立 mysql 的安裝目錄及資料庫存放目錄 

1
2
[root@Betty mysql-5.6.10]# mkdir -p /usr/local/mysql
[root@Betty mysql-5.6.10]# mkdir -p /usr/local/mysql/data


(3)建立 mysql 使用者及使用者組 

1
2
3
4
5
[root@Betty mysql-5.6.10]# groupadd mysql
groupadd: group mysql exists
[root@Betty mysql-5.6.10]# useradd -r -g mysql mysql
useradd: user mysql exists
[root@Betty mysql-5.6.10]#

因為我之前已經安裝過一次,所以上面說使用者組和使用者已存在。 

(4)安裝 mysql 

引數說明: 

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql    //安裝目錄 
-DINSTALL_DATADIR=/usr/local/mysql/data     //資料庫存放目錄 
-DDEFAULT_CHARSET=utf8                            //使用utf8字元 
-DDEFAULT_COLLATION=utf8_general_ci          //校驗字元 
-DEXTRA_CHARSETS=all                                  //安裝所有擴充套件字符集 
-DENABLED_LOCAL_INFILE=1                          //允許從本地匯入資料 

執行 cmake 命令。 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[root@Betty mysql-5.6.10]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1
-- Running cmake version 2.8.10.2
-- The C compiler identification is GNU 4.1.2
-- The CXX compiler identification is GNU 4.1.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
......
-- Check size of pthread_t
-- Check size of pthread_t - done
-- Performing Test HAVE_PEERCRED
-- Performing Test HAVE_PEERCRED - Success
-- Googlemock was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://foo.bar.com:80
Warning: Bison executable not found in PATH
-- Configuring done
-- Generating done
-- Build files have been written to: /root/Me_wget/mysql-5.6.10
[root@Betty mysql-5.6.10]#

執行 make 命令。 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
[root@Betty mysql-5.6.10]# make
Scanning dependencies of target INFO_BIN
[  0%] Built target INFO_BIN
Scanning dependencies of target INFO_SRC
[  0%] Built target INFO_SRC
Scanning dependencies of target abi_check
[  0%] Built target abi_check
Scanning dependencies of target zlib
[  0%] Building C object zlib/CMakeFiles/zlib.dir/adler32.c.o
[  0%] Building C object zlib/CMakeFiles/zlib.dir/compress.c.o
[  0%] Building C object zlib/CMakeFiles/zlib.dir/crc32.c.o
[  0%] Building C object zlib/CMakeFiles/zlib.dir/deflate.c.o
[  0%] Building C object zlib/CMakeFiles/zlib.dir/gzio.c.o
....
Linking CXX static library libsql_embedded.a
[ 99%] Built target sql_embedded
[ 99%] Generating mysqlserver_depends.c
Scanning dependencies of target mysqlserver
[ 99%] Building C object libmysqld/CMakeFiles/mysqlserver.dir/mysqlserver_depends.c.o
Linking C static library libmysqld.a
/usr/bin/ar: creating /root/Me_wget/mysql-5.6.10/libmysqld/libmysqld.a
[ 99%] Built target mysqlserver
Scanning dependencies of target mysql_client_test_embedded
[ 99%] Building C object libmysqld/examples/CMakeFiles/mysql_client_test_embedded.dir/__/__/tests/mysql_client_test.c.o
Linking CXX executable mysql_client_test_embedded
[ 99%] Built target mysql_client_test_embedded
Scanning dependencies of target mysql_embedded
[ 99%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/completion_hash.cc.o
[ 99%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/mysql.cc.o
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/readline.cc.o
Linking CXX executable mysql_embedded
[100%] Built target mysql_embedded
Scanning dependencies of target mysqltest_embedded
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysqltest_embedded.dir/__/__/client/mysqltest.cc.o
Linking CXX executable mysqltest_embedded
[100%] Built target mysqltest_embedded
Scanning dependencies of target my_safe_process
[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o
Linking CXX executable my_safe_process
[100%] Built target my_safe_process

執行 make install 命令。 

1
2
3
4
5
6
7
8
9
10
11
[root@Betty mysql-5.6.10]# make install
[  0%] Built target INFO_BIN
[  0%] Built target INFO_SRC
[  0%] Built target abi_check
[  1%] Built target zlib
[  2%] Built target yassl
[  4%] Built target taocrypt
[  6%] Built target edit
[ 10%] Built target strings
[ 18%] Built target mysys
......


(5)設定目錄許可權 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
[root@Betty mysql-5.6.10]# cd /usr/local/mysql
[root@Betty mysql]# ll
total 76
-rw-r--r--  1 root root 17987 Jan 23 00:54 COPYING
-rw-r--r--  1 root root  7468 Jan 23 00:55 INSTALL-BINARY
-rw-r--r--  1 root root  2552 Jan 23 00:54 README
drwxr-xr-x  2 root root  4096 May  6 13:57 bin
drwxr-xr-x  4 root root  4096 May  6 13:57 data
drwxr-xr-x  2 root root  4096 May  6 13:58 docs
drwxr-xr-x  3 root root  4096 May  6 13:57 include
drwxr-xr-x  3 root root  4096 May  6 13:57 lib
drwxr-xr-x  4 root root  4096 May  6 13:57 man
drwxr-xr-x 10 root root  4096 May  6 13:57 mysql-test
drwxr-xr-x  2 root root  4096 May  6 13:57 scripts
drwxr-xr-x 28 root root  4096 May  6 13:57 share
drwxr-xr-x  4 root root  4096 May  6 13:57 sql-bench
drwxr-xr-x  3 root root  4096 May  6 13:57 support-files
[root@Betty mysql]# chown -R root:mysql .
[root@Betty mysql]# ll
total 76
-rw-r--r--  1 root mysql 17987 Jan 23 00:54 COPYING
-rw-r--r--  1 root mysql  7468 Jan 23 00:55 INSTALL-BINARY
-rw-r--r--  1 root mysql  2552 Jan 23 00:54 README
drwxr-xr-x  2 root mysql  4096 May  6 13:57 bin
drwxr-xr-x  4 root mysql  4096 May  6 13:57 data
drwxr-xr-x  2 root mysql  4096 May  6 13:58 docs
drwxr-xr-x  3 root mysql  4096 May  6 13:57 include
drwxr-xr-x  3 root mysql  4096 May  6 13:57 lib
drwxr-xr-x  4 root mysql  4096 May  6 13:57 man
drwxr-xr-x 10 root mysql  4096 May  6 13:57 mysql-test
drwxr-xr-x  2 root mysql  4096 May  6 13:57 scripts
drwxr-xr-x 28 root mysql  4096 May  6 13:57 share
drwxr-xr-x  4 root mysql  4096 May  6 13:57 sql-bench
drwxr-xr-x  3 root mysql  4096 May  6 13:57 support-files
[root@Betty mysql]# chown -R mysql:mysql data
[root@Betty mysql]# ll
total 76
-rw-r--r--  1 root  mysql 17987 Jan 23 00:54 COPYING
-rw-r--r--  1 root  mysql  7468 Jan 23 00:55 INSTALL-BINARY
-rw-r--r--  1 root  mysql  2552 Jan 23 00:54 README
drwxr-xr-x  2 root  mysql  4096 May  6 13:57 bin
drwxr-xr-x  4 mysql mysql  4096 May  6 13:57 data
drwxr-xr-x  2 root  mysql  4096 May  6 13:58 docs
drwxr-xr-x  3 root  mysql  4096 May  6 13:57 include
drwxr-xr-x  3 root  mysql  4096 May  6 13:57 lib
drwxr-xr-x  4 root  mysql  4096 May  6 13:57 man
drwxr-xr-x 10 root  mysql  4096 May  6 13:57 mysql-test
drwxr-xr-x  2 root  mysql  4096 May  6 13:57 scripts
drwxr-xr-x 28 root  mysql  4096 May  6 13:57 share
drwxr-xr-x  4 root  mysql  4096 May  6 13:57 sql-bench
drwxr-xr-x  3 root  mysql  4096 May  6 13:57 support-files
[root@Betty mysql]#

       上述命令將資料目錄 data 的所屬使用者和所屬使用者組均設定為 mysql ,而將 mysql 目錄下的其他檔案的所屬使用者設定為 root ,所屬組設定為 mysql 。 


(6)設定 mysql 配置檔案 

1
[root@Betty mysql]# cp support-files/my-default.cnf /etc/my.cnf


(7)建立系統資料庫的表 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
[root@Betty mysql]# scripts/mysql_install_db --user=mysql
Installing MySQL system tables...2013-05-06 15:22:18 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-05-06 15:22:18 19328 [Note] InnoDB: The InnoDB memory heap is disabled
2013-05-06 15:22:18 19328 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2013-05-06 15:22:18 19328 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-05-06 15:22:18 19328 [Note] InnoDB: CPU does not support crc32 instructions
2013-05-06 15:22:18 19328 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2013-05-06 15:22:18 19328 [Note] InnoDB: Completed initialization of buffer pool
2013-05-06 15:22:18 19328 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2013-05-06 15:22:18 19328 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2013-05-06 15:22:18 19328 [Note] InnoDB: Database physically writes the file full: wait...
2013-05-06 15:22:18 19328 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2013-05-06 15:22:20 19328 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2013-05-06 15:22:21 19328 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2013-05-06 15:22:21 19328 [Warning] InnoDB: New log files created, LSN=45781
2013-05-06 15:22:21 19328 [Note] InnoDB: Doublewrite buffer not found: creating new
2013-05-06 15:22:21 19328 [Note] InnoDB: Doublewrite buffer created
2013-05-06 15:22:21 19328 [Note] InnoDB: 128 rollback segment(s) are active.
2013-05-06 15:22:21 19328 [Warning] InnoDB: Creating foreign key constraint system tables.
2013-05-06 15:22:21 19328 [Note] InnoDB: Foreign key constraint system tables created
2013-05-06 15:22:21 19328 [Note] InnoDB: Creating tablespace and datafile system tables.
2013-05-06 15:22:21 19328 [Note] InnoDB: Tablespace and datafile system tables created.
2013-05-06 15:22:21 19328 [Note] InnoDB: Waiting for purge to start
2013-05-06 15:22:21 19328 [Note] InnoDB: 1.2.10 started; log sequence number 0
2013-05-06 15:22:21 19328 [Note] Binlog end
2013-05-06 15:22:21 19328 [Note] InnoDB: FTS optimize thread exiting.
2013-05-06 15:22:21 19328 [Note] InnoDB: Starting shutdown...
2013-05-06 15:22:22 19328 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
 
 
Filling help tables...2013-05-06 15:22:22 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-05-06 15:22:22 19351 [Note] InnoDB: The InnoDB memory heap is disabled
2013-05-06 15:22:22 19351 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2013-05-06 15:22:22 19351 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-05-06 15:22:22 19351 [Note] InnoDB: CPU does not support crc32 instructions
2013-05-06 15:22:22 19351 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2013-05-06 15:22:22 19351 [Note] InnoDB: Completed initialization of buffer pool
2013-05-06 15:22:22 19351 [Note] InnoDB: Highest supported file format is Barracuda.
2013-05-06 15:22:22 19351 [Note] InnoDB: 128 rollback segment(s) are active.
2013-05-06 15:22:22 19351 [Note] InnoDB: Waiting for purge to start
2013-05-06 15:22:22 19351 [Note] InnoDB: 1.2.10 started; log sequence number 1625977
2013-05-06 15:22:23 19351 [Note] Binlog end
2013-05-06 15:22:23 19351 [Note] InnoDB: FTS optimize thread exiting.
2013-05-06 15:22:23 19351 [Note] InnoDB: Starting shutdown...
2013-05-06 15:22:24 19351 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK
 
 
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
 
 
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
 
 
  ./bin/mysqladmin -u root password `new-password`
  ./bin/mysqladmin -u root -h Betty password `new-password`
 
 
Alternatively you can run:
 
 
  ./bin/mysql_secure_installation
 
 
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
 
 
See the manual for more instructions.
 
 
You can start the MySQL daemon with:
 
 
  cd . ; ./bin/mysqld_safe &
 
 
You can test the MySQL daemon with mysql-test-run.pl
 
 
  cd mysql-test ; perl mysql-test-run.pl
 
 
Please report any problems with the ./bin/mysqlbug script!
 
 
The latest information about MySQL is available on the web at
 
 
  http://www.mysql.com
 
 
Support MySQL by buying support/licenses at http://shop.mysql.com
 
 
New default config file was created as ./my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
 
 
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
 
 
[root@Betty mysql]#


(8)設定環境變數 

1
[root@Betty mysql]# vi /root/.bash_profile 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# .bash_profile
 
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
 
# User specific environment and startup programs
 
#PATH=$PATH:$HOME/bin
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
 
export PATH
unset USERNAME 
1
[root@Betty mysql]# source /root/.bash_profile


(9)啟動 mysql 伺服器 


       若想使用 service 命令啟動 mysql 需要將 mysql 啟動指令碼 support-files/mysql.server 新增到 /etc/init.d 目錄下,如下設定:  

1
2
3
4
5
[root@Betty mysql]# cp support-files/mysql.server  /etc/init.d/mysql
[root@Betty mysql]# ll /etc/init.d/mysql 
-rwxr-xr-x 1 root root 10650 May  6 14:11 /etc/init.d/mysql
[root@Betty mysql]# /etc/init.d/mysql start
Starting MySQL.                                            [  OK  ] 
1
2
3
4
5
[root@Betty mysql]# ps aux|grep mysql
root      4070  0.0  0.0   8732  1168 pts/1    S    14:51   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/Betty.pid
mysql     4185  0.0  2.2 447880 86952 pts/1    Sl   14:51   0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/Betty.err --pid-file=/usr/local/mysql/data/Betty.pid
root      4221  0.0  0.0   6064   572 pts/1    S+   14:54   0:00 grep mysql
[root@Betty mysql]#


(10)為 root 賬號新增遠端連線的能力 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
[root@Betty ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 7
Server version: 5.6.10-log 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> 
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
 
Database changed
 
 
mysql> 
mysql> desc user;
+------------------------+-----------------------------------+------+-----+---------+-------+
| Field                  | Type                              | Null | Key | Default | Extra |
+------------------------+-----------------------------------+------+-----+---------+-------+
| Host                   | char(60)                          | NO   | PRI |         |       |
| User                   | char(16)                          | NO   | PRI |         |       |
| Password               | char(41)                          | NO   |     |         |       |
| Select_priv            | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Insert_priv            | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Update_priv            | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Delete_priv            | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Create_priv            | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Drop_priv              | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Reload_priv            | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Shutdown_priv          | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Process_priv           | enum(`N`,`Y`)                     | NO   |     | N       |       |
| File_priv              | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Grant_priv             | enum(`N`,`Y`)                     | NO   |     | N       |       |
| References_priv        | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Index_priv             | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Alter_priv             | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Show_db_priv           | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Super_priv             | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Create_tmp_table_priv  | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Lock_tables_priv       | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Execute_priv           | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Repl_slave_priv        | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Repl_client_priv       | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Create_view_priv       | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Show_view_priv         | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Create_routine_priv    | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Alter_routine_priv     | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Create_user_priv       | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Event_priv             | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Trigger_priv           | enum(`N`,`Y`)                     | NO   |     | N       |       |
| Create_tablespace_priv | enum(`N`,`Y`)                     | NO   |     | N       |       |
| ssl_type               | enum(``,`ANY`,`X509`,`SPECIFIED`) | NO   |     |         |       |
| ssl_cipher             | blob                              | NO   |     | NULL    |       |
| x509_issuer            | blob                              | NO   |     | NULL    |       |
| x509_subject           | blob                              | NO   |     | NULL    |       |
| max_questions          | int(11) unsigned                  | NO   |     | 0       |       |
| max_updates            | int(11) unsigned                  | NO   |     | 0       |       |
| max_connections        | int(11) unsigned                  | NO   |     | 0       |       |
| max_user_connections   | int(11) unsigned                  | NO   |     | 0       |       |
| plugin                 | char(64)                          | YES  |     |         |       |
| authentication_string  | text                              | YES  |     | NULL    |       |
| password_expired       | enum(`N`,`Y`)                     | NO   |     | N       |       |
+------------------------+-----------------------------------+------+-----+---------+-------+
43 rows in set (0.00 sec)
 
 
mysql> 
mysql> 
mysql> select host,user,password from user;
+-----------+------+----------+
| host      | user | password |
+-----------+------+----------+
| localhost | root |          |
| Betty     | root |          |
| 127.0.0.1 | root |          |
| ::1       | root |          |
| localhost |      |          |
| Betty     |      |          |
+-----------+------+----------+
6 rows in set (0.00 sec)
 
 
mysql> 
mysql> 
mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";
Query OK, 0 rows affected (0.00 sec)
 
 
mysql> select host,user,password from user;
+-----------+------+-------------------------------------------+
| host      | user | password                                  |
+-----------+------+-------------------------------------------+
| localhost | root |                                           |
| Betty     | root |                                           |
| 127.0.0.1 | root |                                           |
| ::1       | root |                                           |
| localhost |      |                                           |
| Betty     |      |                                           |
| %         | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+-----------+------+-------------------------------------------+
7 rows in set (0.00 sec)
 
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
 
mysql> 
mysql> exit
Bye
[root@Betty ~]#


(11)刪除本機匿名連線的空密碼帳號 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
[root@Betty ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 7
Server version: 5.6.10-log 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> 
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
 
Database changed
mysql> 
mysql> select Host,User,Password from user;
+-----------+------+-------------------------------------------+
| Host      | User | Password                                  |
+-----------+------+-------------------------------------------+
| localhost | root |                                           |
| Betty     | root |                                           |
| 127.0.0.1 | root |                                           |
| ::1       | root |                                           |
| localhost |      |                                           |
| Betty     |      |                                           |
| %         | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+-----------+------+-------------------------------------------+
7 rows in set (0.00 sec)
 
 
mysql> delete from user where password="";
Query OK, 6 rows affected (0.00 sec)
 
 
mysql> 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
 
mysql> 
mysql> select Host,User,Password from user;
+------+------+-------------------------------------------+
| Host | User | Password                                  |
+------+------+-------------------------------------------+
| %    | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+------+------+-------------------------------------------+
1 row in set (0.00 sec)
 
 
mysql> 
mysql>


相關文章