Linux mysql.plugin_Linux下MySQL安装

博主邮箱www.zzher@foxmail.com qq:1102471911

1 //获得以下所需的源代码包(文末附有安装包),并存放在/usr/local/src

2 //与mysql相关:3 boost_1_59_0.tar.gz cmake-3.6.2.tar.gz mysql-5.7.16.tar.gz4

5 //安装cmake前的依赖包的安装6 //检查gcc-c++ 、ncurses-devel是否安装,如果没有安装,先用yum进行安装7

8 编译安装cmake工具9 cd /usr/local/src

10 tar xf cmake-3.6.2.tar.gz11 cd cmake-3.6.2

12 ./bootstrap --prefix=/usr/local/cmake13 make14 make install #如果前面没有指定安装目录,则默认安装到/usr/local/bin/cmake15

16 建立mysql组和用户,并将mysql用户添加到mysql组17 groupadd mysql18 useradd -g mysql mysql19 创建mysql数据文件存放的目录20 mkdir /mydata

21 chown mysql:mysql /mydata

22 chmod o= /mydata #设置其他人没有任何权限

23

24 编译安装mysql25 cd /usr/local/src

26 tar xf mysql-5.7.16.tar.gz27 cd mysql-5.7.16

28 /usr/local/cmake/bin/cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mydata -DWITH_BOOST=/usr/local/src -DSYSCONFDIR=/etc -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_DEBUG=0 -DMYSQL_MAINTAINER_MODE=0 -DWITH_SSL:STRING=bundled -DWITH_ZLIB:STRING=bundled

29 make &&make install30

31 更改mysql安装目录的属主属组并添加mysql环境变量32 chown -R mysql:mysql /usr/local/mysql

33 vim /etc/profile.d/mysql.sh

34 文件内容是:35 export PATH=$PATH:/usr/local/mysql/bin36 执行命令:37 bash #让新的PATH变量生效38

39 加入服务列表并设置为开机自启40 cd /usr/local/mysql/support-files41 cp mysql.server /etc/init.d/mysqld

42 chmod +x /etc/init.d/mysqld

43 chkconfig mysqld on44

45 修改mysql的配置文件46 cat /etc/my.cnf47

48 [mysql]49 socket=/tmp/mysql.sock50

51 [mysqld]52 datadir=/mydata

53 socket=/tmp/mysql.sock54 user=mysql55 symbolic-links=0

56

57 [mysqld_safe]58 log-error=/var/log/mysqld.log

59 pid-file=/mydata/mysqld.pid60

61 初始化mysql62 mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/mydata63 说明:64 ##“-–initialize”会生成一个随机密码(~/.mysql_secret),而”–initialize-insecure”不会生成密码 ##user表示指定用户 ##basedir表示mysql的安装路径,datadir表示数据库文件存放路径

65

66 启动mysql服务67 # service mysqld start68 查看MySQL服务的进程和端口69 # ps -ef |grep mysqld70 root 22306 1 0 12:51 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/mydata --pid-file=/mydata/web1.deng.com.pid

71 mysql 22480 22306 12 12:51 pts/0 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/mydata --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/mydata/web1.deng.com.pid --socket=/tmp/mysql.sock72

73 # netstat -an | grep :3306

74 tcp 0 0 :::3306 :::*LISTEN75

76 初始化MySQL数据库的root用户密码77 # mysql_secure_installation78

79 Securing the MySQL server deployment.80

81 Connecting to MySQL using a blank password.82

83 VALIDATE PASSWORD PLUGIN can be used to test passwords84 and improve security. It checks the strength of password85 and allows the users to set only those passwords which are86 secure enough. Would you like to setup VALIDATE PASSWORD plugin?

87

88 Press y|Y for Yes, any other key forNo: y #需要修改密码,所以输入y89

90 There are three levels of password validation policy:91

92 LOW Length >= 8

93 MEDIUM Length >= 8, numeric, mixed case, and special characters94 STRONG Length >= 8, numeric, mixed case, special characters and dictionary file95

96 Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2#设置密码复杂度为强97 Please set the password forroot here.98

99 New password:100

101 Re-enter newpassword: #输入2次新密码102

103 Estimated strength of the password: 100

104 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key forNo) : y105 By default, a MySQL installation has an anonymous user,106 allowing anyone to log into MySQL without having to have107 a user account created for them. This is intended only for

108 testing, and to make the installation go a bit smoother.109 You should remove them before moving into a production110 environment.111

112 Remove anonymous users? (Press y|Y for Yes, any other key forNo) : y #删除匿名用户113 Success.114

115

116 Normally, root should only be allowed to connect from117 'localhost'. This ensures that someone cannot guess at118 the root password from the network.119

120 Disallow root login remotely? (Press y|Y for Yes, any other key forNo) : y #禁止root远程登录121

122 ... skipping.123 By default, MySQL comes with a database named 'test'that124 anyone can access. This is also intended only fortesting,125 and should be removed before moving into a production126 environment.127

128

129 Remove test database and access to it? (Press y|Y for Yes, any other key forNo) : y #删除测试数据库130 -Dropping test database...131 Success.132

133 -Removing privileges on test database...134 Success.135

136 Reloading the privilege tables will ensure that all changes137 made so far will take effect immediately.138

139 Reload privilege tables now? (Press y|Y for Yes, any other key forNo) : y #重新加载权限表140 Success.141

142 All done!

143

144 将MySQL数据库的动态链接库共享至系统链接库145 vim /etc/ld.so.conf.d/mysql.conf

146 文件内容是:147 /usr/local/mysql/lib148

149 ldconfig -v 让系统重新读取库文件150

151 测试登陆MySQL数据库152 # mysql -uroot -p153 Enter password: #输入刚才设置的新密码154 Welcome to the MySQL monitor. Commands end with; or \g.155 Your MySQL connection id is 5

156 Server version: 5.7.14Source distribution157

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

159

160 Oracle is a registered trademark of Oracle Corporation and/or its

161 affiliates. Other names may be trademarks of their respective162 owners.163

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

166 mysql>show databases;167 +--------------------+

168 | Database |

169 +--------------------+

170 | information_schema |

171 | mysql |

172 | performance_schema |

173 | sys |

174 +--------------------+

175 4 rows in set (0.00sec)176

177 mysql>exit178 Bye

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值