【整理】源码安装 mysql-5.6.10

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:
       参考别人的经验,加上自己的理解,完成下面的动作。

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


【源码安装 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>

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
关系型数据库 MySQL 数据库
mysql源码安装详解
mysql源码安装详解
278 0
mysql源码安装详解
|
8月前
|
关系型数据库 MySQL C语言
源码安装MySQL8.0 1
源码安装MySQL8.0
|
6月前
|
关系型数据库 MySQL
麒麟系统源码安装mysql
麒麟系统源码安装mysql
|
8月前
|
关系型数据库 MySQL 数据安全/隐私保护
源码安装MySQL8.0 2
源码安装MySQL8.0
|
9月前
|
关系型数据库 MySQL Linux
阿里云linux源码安装mysql
阿里云linux源码安装mysql
|
11月前
|
存储 关系型数据库 MySQL
源码安装MySQL-5.7.38的脚本
源码安装MySQL-5.7.38的脚本
168 1
|
关系型数据库 MySQL Linux
linux(Centos)源码包安装 mysql-5.7.20.tar.gz
linux(Centos)源码包安装 mysql-5.7.20.tar.gz
192 0
linux(Centos)源码包安装 mysql-5.7.20.tar.gz
|
存储 Oracle 关系型数据库
MySQL源码安装
mysql是一个开源的关系型数据库管理系统,现在是oracle公司旗下的一款产品,由C和C++语言编写,可移植性高。 支持在多种操作系统上安装,最常见有AIX,linux,window。mysql因为开源免费,所以受到了目前互联网行业的 欢迎。 以mysql作为数据库,linux系统作为操作系统,apache或者nginx作为web服务器,perl/php/python作为服务 端的脚本解释器,就可以搭建起一个免费的网站。被业界称为LNMP或者LAMP
171 0
|
Ubuntu 关系型数据库 MySQL
linux篇-linux mysql5.6.27源码安装和错误解决
linux篇-linux mysql5.6.27源码安装和错误解决
447 0
linux篇-linux mysql5.6.27源码安装和错误解决
|
关系型数据库 MySQL Linux
Linux7.6源码安装Mysql8.0.27,历时1周整理
Linux7.6源码安装Mysql8.0.27,历时1周整理
336 0
Linux7.6源码安装Mysql8.0.27,历时1周整理