参考别人的经验,加上自己的理解,完成下面的动作。
==============================
【源码安装 mysql-5.6.10】
(1)解压 mysql 源码
1 2 |
|
(2)创建 mysql 的安装目录及数据库存放目录
1 2 |
|
(3)创建 mysql 用户及用户组
1 2 3 4 5 |
|
因为我之前已经安装过一次,所以上面说用户组和用户已存在。
(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 |
|
执行 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 |
|
执行 make install 命令。
1 2 3 4 5 6 7 8 9 10 11 |
|
(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 |
|
上述命令将数据目录 data 的所属用户和所属用户组均设置为 mysql ,而将 mysql 目录下的其他文件的所属用户设置为 root ,所属组设置为 mysql 。
(6)设置 mysql 配置文件
1 |
|
(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 |
|
(8)设置环境变量
1 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
1 |
|
(9)启动 mysql 服务器
若想使用 service 命令启动 mysql 需要将 mysql 启动脚本 support-files/mysql.server 添加到 /etc/init.d 目录下,如下设置:
1 2 3 4 5 |
|
1 2 3 4 5 |
|
(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 |
|
(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 |
|