-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
373 lines (212 loc) · 13.2 KB
/
index.html
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
<meta charset="utf-8">
<title>简单的Coder</title>
<meta name="author" content="dlutcat">
<meta name="description" content="昨天帮朋友安装部署Mysql的时候,用mysqladmin给root用户设置了一个16位的随机密码,还没来得及记下来就被突然插进来的事儿打断了,等我回来的时候已经找不到这个密码了。像这样的事情在我身上已经发生过了2次,每次Google『Mysql忘记root密码』都没有找到可行的方案( …">
<!-- http://t.co/dKP3o1e -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="canonical" href="http://chenglei.me/">
<link href="/favicon.png" rel="icon">
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
<script src="/javascripts/modernizr-2.0.js"></script>
<script src="/javascripts/ender.js"></script>
<script src="/javascripts/octopress.js" type="text/javascript"></script>
<link href="/atom.xml" rel="alternate" title="简单的Coder" type="application/atom+xml">
<!--Fonts from Google"s Web font directory at http://google.com/webfonts -->
<link href="http://fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-39137609-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body >
<header role="banner"><hgroup>
<h1><a href="/">简单的Coder</a></h1>
<h2>Code is my life, that's it.</h2>
</hgroup>
</header>
<nav role="navigation"><ul class="subscription" data-subscription="rss">
<li><a href="/atom.xml" rel="subscribe-rss" title="subscribe via RSS">RSS</a></li>
</ul>
<form action="http://google.com/search" method="get">
<fieldset role="search">
<input type="hidden" name="q" value="site:chenglei.me" />
<input class="search" type="text" name="q" results="0" placeholder="Search"/>
</fieldset>
</form>
<ul class="main-navigation">
<li><a href="/">首页</a></li>
<li><a href="/blog/archives">归档</a></li>
<li><a href="/about">关于</a></li>
</ul>
</nav>
<div id="main">
<div id="content">
<div class="blog-index">
<article>
<header>
<h1 class="entry-title"><a href="/blog/2013/05/02/zhong-xin-she-zhi-mysqlde-rootmi-ma/">重新设置Mysql的root密码</a></h1>
<p class="meta">
<time datetime="2013-05-02T20:07:00+08:00" pubdate data-updated="true">May 2<span>nd</span>, 2013</time>
</p>
</header>
<div class="entry-content"><p>昨天帮朋友安装部署Mysql的时候,用<code>mysqladmin</code>给root用户设置了一个16位的随机密码,还没来得及记下来就被突然插进来的事儿打断了,等我回来的时候已经找不到这个密码了。像这样的事情在我身上已经发生过了2次,每次Google『Mysql忘记root密码』都没有找到可行的方案(可能是因为Mysql版本和网上这些提到的不一样导致重置失败),所以这次我要记下来一个自己确认可行的方案以供今后参考。</p>
<h2>我的环境版本</h2>
<ul>
<li>CentOS release 6.3 (Final)</li>
<li>mysql Ver 14.14 Distrib 5.1.69, for redhat-linux-gnu (x86_64) using readline 5.1</li>
</ul>
<h2>问题描述</h2>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>mysqladmin -u root -p randompassword
</span></code></pre></td></tr></table></div></figure>
<p>之后,忘记了<code>randompassword</code>,无法登陆<code>mysql</code>,需要找回root密码。</p>
<h2>解决方案</h2>
<ol>
<li>修改<code>mysqld</code>的配置文件`/etc/my.cnf’,在每个section里追加一条设置:「skip-grant-tables 」,比如:</li>
</ol>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="o">[</span>mysqld<span class="o">]</span>
</span><span class='line'><span class="nv">datadir</span><span class="o">=</span>/var/lib/mysql
</span><span class='line'><span class="nv">socket</span><span class="o">=</span>/var/lib/mysql/mysql.sock
</span><span class='line'>skip-grant-tables
</span></code></pre></td></tr></table></div></figure>
<ol>
<li>重启<code>mysqld</code>。</li>
<li>登陆<code>mysql</code>,修改root密码。</li>
</ol>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>> mysql -u root
</span><span class='line'>mysql> USE mysql;
</span><span class='line'>mysql> UPDATE user SET <span class="nv">Password</span><span class="o">=</span>password <span class="o">(</span><span class="s1">'new-password'</span><span class="o">)</span> WHERE <span class="nv">User</span> <span class="o">=</span> <span class="s1">'root'</span>;
</span><span class='line'>mysql> FLUSH PRIVILEGES;
</span></code></pre></td></tr></table></div></figure>
<ol>
<li>将<code>/etc/my.cnf</code>更改回来。</li>
<li>重启<code>mysqld</code>。</li>
</ol>
<p><span style="color: red;">注意: </span>「skip-grant-tables」模式是忽略权限认证的意思,所以在上述<code>步骤1</code>开始前先保证外人无法连接你的<code>mysqld</code>。</p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2013/04/26/alfred-workflow-shi-yao-zhi-de-mai/">Alfred Workflow: 什么值得买</a></h1>
<p class="meta">
<time datetime="2013-04-26T18:08:00+08:00" pubdate data-updated="true">Apr 26<span>th</span>, 2013</time>
</p>
</header>
<div class="entry-content"><p>作为一个命令行控,一向能用命令的我都会用命令。记得5,6年前Firefox有一个扩展叫做Ubiquity,相当于浏览器上的一个Shell,用户可以通过Web技术开发命令行工具,比如Gmail, Map, 点评等,不知后来此项目为什么夭折了。</p>
<p>什么是Alfred的workflow?如果你是Mac用户,那么你可以看看<a href="http://www.alfredapp.com/powerpack/">官方介绍</a>。 <br/>
今天有点时间为<a href="http://www.smzdm.com">什么值得买</a>写了一个Alfred的workflow: <a href="https://github.com/dlutcat/alfred-smzdm-workflow">alfred-smzdm-workflow</a>,方便随时查看smzdm最新发布的优惠信息。</p>
<p>下载:<a href="https://github.com/dlutcat/alfred-smzdm-workflow/blob/master/smzdm.alfredworkflow?raw=true">smzdm.alfredworkflow</a><br/>
源码:<a href="https://github.com/dlutcat/alfred-smzdm-workflow">Github</a><br/>
截图:<br/>
<img src="http://img1.kantuban.com/pin/f816f2f8817aa2a698a8f84185f8ac5c" alt="" /></p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2013/03/08/macying-wen-xi-tong-xia-itunesdao-ru-zhong-wen-ge-qu-luan-ma-de-jie-jue-fang-fa/">Mac英文系统下iTunes导入中文歌曲乱码的解决方法</a></h1>
<p class="meta">
<time datetime="2013-03-08T20:09:00+08:00" pubdate data-updated="true">Mar 8<span>th</span>, 2013</time>
</p>
</header>
<div class="entry-content"><p>为了命令行的方便,我的Mac一直用的都是英文的系统。今天我往iTunes里导入中文歌曲的时候发现歌曲名,专辑名,作者名全是乱码,网上搜到的解决方案没有几个靠谱的。于是,还是自己用Python写了个脚本来搞定吧。</p>
<p>我的MP3文件的ID3信息编码都是GBK的,把它转成UTF8就OK了。读写ID3信息的库我用的是<a href="https://code.google.com/p/mutagen/">Mutagen</a>,接口简单,示例文档小巧。我在转编码的时候遇到一个难点,就是怎么把下面unicode中的编码decode?</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='python'><span class='line'><span class="n">s</span> <span class="o">=</span> <span class="s">u"COMM=='chi'=www.lizhizhuangbi.com</span><span class="se">\n</span><span class="s">TALB=</span><span class="se">\xb1\xbb\xbd\xfb\xbc\xc9\xb5\xc4\xd3\xce\xcf\xb7\n</span><span class="s">TDRC=2004</span><span class="se">\n</span><span class="s">TIT2=</span><span class="se">\xbf\xa8\xb7\xf2\xbf\xa8\n</span><span class="s">TPE1=</span><span class="se">\xc0\xee\xd6\xbe\n</span><span class="s">TPE2=</span><span class="se">\xc0\xee\xd6\xbe</span><span class="s">"</span>
</span></code></pre></td></tr></table></div></figure>
<p>看上去原信息是GBK编码,可是怎么decode呢?Mutagen返回的直接就是unicode,没法decode 。最后只能尝试直接读取字符流,然后按照GBK来decode才成功。下面的<code>decode_gbk_from_unicode(s)</code>就是实现逻辑。</p>
<div><script src='https://gist.github.com/5115640.js'></script>
<noscript><pre><code></code></pre></noscript></div>
</div>
</article>
<div class="pagination">
<a class="prev" href="/blog/page/2/">← Older</a>
<a href="/blog/archives">所有日志</a>
</div>
</div>
<aside class="sidebar">
<section>
<h1>Recent Posts</h1>
<ul id="recent_posts">
<li class="post">
<a href="/blog/2013/05/02/zhong-xin-she-zhi-mysqlde-rootmi-ma/">重新设置Mysql的root密码</a>
</li>
<li class="post">
<a href="/blog/2013/04/26/alfred-workflow-shi-yao-zhi-de-mai/">Alfred workflow: 什么值得买</a>
</li>
<li class="post">
<a href="/blog/2013/03/08/macying-wen-xi-tong-xia-itunesdao-ru-zhong-wen-ge-qu-luan-ma-de-jie-jue-fang-fa/">Mac英文系统下iTunes导入中文歌曲乱码的解决方法</a>
</li>
<li class="post">
<a href="/blog/2013/02/08/linuxzhong-duan-chang-yong-ji-qiao-zong-jie-wei-xin-linuxtipsgui-dang/">微信公众账号LinuxTips归档</a>
</li>
<li class="post">
<a href="/blog/2012/12/17/chi-kai-xiao-yuan-jin-ru-she-hui-xu-yao-ming-bai-de-ji-jian-shi-qing/">离开校园进入社会需要明白的几件事情</a>
</li>
</ul>
</section>
<script type="text/javascript" src="http://www.kantuban.com/outwidget/1365"></script>
<section>
<h1>新浪微博</h1>
<ul id="weibo">
<li>
<iframe
width="100%"
height="550"
class="share_self"
frameborder="0"
scrolling="no"
src="http://widget.weibo.com/weiboshow/index.php?width=0&height=550&ptype=1&speed=0&skin=&isTitle=0&noborder=1&isWeibo=1&isFans=&uid=1645930380&verifier=f8d37ee6">
</iframe>
</li>
</ul>
</section>
</aside>
</div>
</div>
<footer role="contentinfo"><p>
Copyright © 2013 - dlutcat -
<span class="credit">Powered by <a href="http://octopress.org">Octopress</a>. Design by <a href="http://octopressthemes.com">Octopress Themes</a>. Background image by <a href="http://www.flickr.com/photos/rhysasplundh/">Rhys Asplundh</a></span>
</p>
</footer>
<script type="text/javascript">
var disqus_shortname = 'simple-coder';
var disqus_script = 'count.js';
(function () {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/' + disqus_script;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
}());
</script>
<script type="text/javascript">
(function(){
var twitterWidgets = document.createElement('script');
twitterWidgets.type = 'text/javascript';
twitterWidgets.async = true;
twitterWidgets.src = 'http://platform.twitter.com/widgets.js';
document.getElementsByTagName('head')[0].appendChild(twitterWidgets);
})();
</script>
</body>
</html>