Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 120210 | Differences between
and this patch

Collapse All | Expand All

(-)mysql-upgrade-slotted.xml (-73 / +89 lines)
Lines 3-34 Link Here
3
<!-- $Header$ -->
3
<!-- $Header$ -->
4
4
5
<guide link="/doc/en/mysql-upgrade-slotted.xml">
5
<guide link="/doc/en/mysql-upgrade-slotted.xml">
6
<title>MySQL, upgrade and switch to slotted guide</title>
6
<title>Slotted MySQL Upgrade and Migration Guide</title>
7
7
8
<author title="Author">
8
<author title="Author">
9
  <mail link="vivo@gentoo.org">Francesco Riosa</mail>
9
  <mail link="vivo@gentoo.org">Francesco Riosa</mail>
10
</author>
10
</author>
11
<author title="Editor">
12
  <mail link="chriswhite@gentoo.org">Chris White</mail>
13
</author>
14
<author title="Editor">
15
  <mail link="jkt@gentoo.org"></mail>
16
</author>
11
17
12
<abstract>
18
<abstract>
13
Here described there is an upgrade path for MySQL databases as painless as
19
This document describes the upgrade path to the new slotted MySQL.  It strives
14
possible.
20
to make the upgrade as painless and friendly as possible.
15
</abstract>
21
</abstract>
16
22
17
<!-- The content of this document is licensed under the CC-BY-SA license -->
23
<!-- The content of this document is licensed under the CC-BY-SA license -->
18
<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
24
<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
19
<license/>
25
<license/>
20
26
21
<version>1</version>
27
<version>1.0</version>
22
<date>2006-01-25</date>
28
<date>2006-01-25</date>
23
29
24
<chapter>
30
<chapter>
25
<title>Upgrading from old versions of MySQL</title>
31
<title>Upgrading Older MySQL Versions</title>
26
<section>
32
<section>
27
<body>
33
<body>
28
34
29
<p>
35
<p>
30
This document cover how to upgrade to the latest version available. There are
36
This document covers how to upgrade to the latest avaliable MySQL version.
31
currently three version of MySQL supported in portage:
37
There are currently three versions of MySQL supported in portage:
32
</p>
38
</p>
33
39
34
<ul>
40
<ul>
Lines 38-57 Link Here
38
</ul>
44
</ul>
39
45
40
<p>
46
<p>
41
There are two additional version presently, but are currently unsupported
47
There are two additional versions present, but are currently unsupported.
42
meaning that bug reports have very low priority any may lack functionalities.
48
This means that bug reports have very low priority any may lack functionalities.
43
The current document is not guaranteed to work with them.
49
This document is not guaranteed to work with them.
44
</p>
50
</p>
45
51
46
<ul>
52
<ul>
47
<li>3.23 ancient</li>
53
<li>3.23 deprecated</li>
48
<li>5.1 active development</li>
54
<li>5.1 active development</li>
49
</ul>
55
</ul>
50
56
51
<note>
57
<note>
52
The present document will use <c>mysql-4.0.26</c> as start point and
58
<c>mysql-4.0.26</c> will be used as start point, and <c>mysql-5.0.18-r30</c> as
53
<c>mysql-5.0.18-r30</c> as the target version. Replace any of these with your
59
the target version. Replace any of these versions with your own.
54
own.
55
</note>
60
</note>
56
61
57
</body>
62
</body>
Lines 60-77 Link Here
60
65
61
66
62
<chapter id="install_the_new_version">
67
<chapter id="install_the_new_version">
63
<title>Install the new version</title>
68
<title>Installing The New Version</title>
64
<section>
69
<section>
65
<body>
70
<body>
66
71
67
<p>
72
<p>
68
This step require to (re)move some files from the running environment, so the
73
This step will require (re)moving some files from the running environment, so
69
first thing to do is a backup of the running database server, still not the
74
the first thing to do is backup the running database server, not the data. Once
70
data. Done that, it's possible to remove the conflicting files with the slotted
75
this is done, it's possible to remove the conflicting files with the slotted
71
MySQL and install the new version side by side with the current one.
76
MySQL, and install the new version side by side with the current one.
72
</p>
77
</p>
73
78
74
<pre caption="Backup old package and prepare installation">
79
<pre caption="Backing up the older version and preparing the installation">
75
# <i>quickpkg dev-db/mysql</i>
80
# <i>quickpkg dev-db/mysql</i>
76
# <i>rm -rf /usr/include/mysql /usr/bin/mysql_config</i>
81
# <i>rm -rf /usr/include/mysql /usr/bin/mysql_config</i>
77
# <i>for tmpfile in  /usr/lib/*mysql* ; do</i>
82
# <i>for tmpfile in  /usr/lib/*mysql* ; do</i>
Lines 82-89 Link Here
82
</pre>
87
</pre>
83
88
84
<p>
89
<p>
85
Be sure to update the <path>/etc/init.d/mysql</path> startup script with
90
Be sure to run <c>etc-update</c> or <c>dispatch-conf</c> in order to update the
86
<c>etc-update</c> or <c>dispatch-conf</c>.
91
<path>/etc/init.d/mysql</path> startup script.
87
</p>
92
</p>
88
93
89
</body>
94
</body>
Lines 91-113 Link Here
91
</chapter>
96
</chapter>
92
97
93
<chapter>
98
<chapter>
94
<title>Copy the data to the newly installed server</title>
99
<title>Copying The Data To The New Server</title>
95
<section>
100
<section>
96
<body>
101
<body>
97
102
98
<p>
103
<p>
99
Lets go to to dump the data, this will be imported in the new version of MySQL.
104
Now we'll go ahead and dump the data. This will be imported into the new
100
We are going to use mysqldump from the <b>slotted</b> MySQL. Notice the
105
version of MySQL. <c>mysqldump</c> will be used from the <b>slotted</b>
101
<c>-500</c> suffix to the mysqldump program name, it's from the <b>5.0</b>.x
106
MySQL. Notice the <c>-500</c> suffix to the <c>mysqldump</c> program name. This
102
version.
107
indicates it's from the <b>5.0</b>.x version.
103
</p>
108
</p>
104
109
110
<impo>
111
If you are upgrading between version revisions (ie. <c>dev-db/mysql-5.0.18</c>
112
to <c>dev-db/mysql-5.0.18-r30</c>), you can simply stop the database, move from
113
one datadir to the other, and restart the server. This allows you to skip this
114
section entirely.
115
</impo>
116
105
<pre caption="Dump of all databases">
117
<pre caption="Dump of all databases">
106
# <i>mysqldump-500 \</i>
118
# <i>mysqldump-500 \</i>
107
  <i>--defaults-file=/etc/mysql/my.cnf</i>
119
  <i>--defaults-file=/etc/mysql/my.cnf \</i>
108
  <i>-uroot \</i>
120
  <i>--user=root \</i>
109
  <i>--password=</i><comment>'your_password'</comment><i> \</i>
121
  <comment>(Replace 'your_password' with your MySQL root password)</comment>
110
  <i>-hlocalhost \</i>
122
  <i>--password='your_password' \</i>
123
  <i>--host=localhost \</i>
111
  <i>--all-databases \</i>
124
  <i>--all-databases \</i>
112
  <i>--opt \</i>
125
  <i>--opt \</i>
113
  <i>--allow-keywords \</i>
126
  <i>--allow-keywords \</i>
Lines 120-126 Link Here
120
</pre>
133
</pre>
121
134
122
<p>
135
<p>
123
Now a file named <path>BACKUP_MYSQL_4.0.SQL</path> exist which can be used to
136
A file named <path>BACKUP_MYSQL_4.0.SQL</path> is created, which can be used to
124
recreate your data. The data is described in the MySQL dialect of SQL, the
137
recreate your data. The data is described in the MySQL dialect of SQL, the
125
Structured Query Language.
138
Structured Query Language.
126
</p>
139
</p>
Lines 129-163 Link Here
129
Start the server without networking and user management and run the SQL script:
142
Start the server without networking and user management and run the SQL script:
130
</p>
143
</p>
131
144
132
<pre caption="Load data">
145
<pre caption="Loading the data">
133
# <i>mv /etc/conf.d/mysql /etc/conf.d/mysql.orig</i>
146
# <i>mv /etc/conf.d/mysql /etc/conf.d/mysql.orig</i>
134
# <i>echo '</i>
147
# <i>cat &lt;&lt;- EOF &gt; /etc/conf.d/mysql</i>
135
  <i>NOCHECK=1</i>
148
  <i>NOCHECK=1</i>
136
  <i>DEBUG=3</i>
149
  <i>DEBUG=3</i>
137
  <i>mysql_slot_500=(</i>
150
  <i>mysql_slot_500=(</i>
138
  <i>  "skip-networking"</i>
151
  <i>  "skip-networking"</i>
139
  <i>  "skip-grant-tables"</i>
152
  <i>  "skip-grant-tables"</i>
140
  <i>)</i>
153
  <i>)</i>
141
  <i>' > /etc/conf.d/mysql</i>
154
  <i>EOF</i>
142
# <i>/etc/init.d/mysql-500 start</i>
155
# <i>/etc/init.d/mysql-500 start</i>
143
# <i>mysql-500 --defaults-file=/etc/mysql-500/my.cnf &lt; BACKUP_MYSQL_4.0.SQL</i>
156
# <i>mysql-500 --defaults-file=/etc/mysql-500/my.cnf &lt; BACKUP_MYSQL_4.0.SQL</i>
144
# <i>mv /etc/conf.d/mysql.orig /etc/conf.d/mysql</i>
145
# <i>/etc/init.d/mysql-500 stop</i>
157
# <i>/etc/init.d/mysql-500 stop</i>
158
# <i>mv /etc/conf.d/mysql.orig /etc/conf.d/mysql</i>
146
</pre>
159
</pre>
147
160
148
<note>
161
<note>
149
To convert the data to UTF-8 during this step you <e>must</e> remove
162
To convert the data to UTF-8 during this step, you <e>must</e> remove
150
<c>--hex-blob</c> from the <c>mysqldump</c> option, then filter the data through
163
<c>--hex-blob</c> from the <c>mysqldump</c> option, then filter the data through
151
a converter like <c>iconv</c>. In most case this is done simply "piping" it like
164
a converter like <c>iconv</c>. In most cases this is done by simply "piping" it
152
<c>iconv -f ISO_8859-1 -t UTF8 BACKUP_MYSQL_4.0.SQL | mysql-500
165
like so: <c>iconv -f ISO_8859-1 -t UTF8 BACKUP_MYSQL_4.0.SQL | mysql-500
153
--defaults-file=/etc/mysql-500/my.cnf</c>. Also manual tweaking of the SQL file
166
--defaults-file=/etc/mysql-500/my.cnf</c>. Manual adjustments of the SQL file
154
could be needed, depending on the structure and the data contained in it.
167
could be required, depending on the structure and the data contained within.
155
</note>
168
</note>
156
169
157
<note>
170
<note>
158
If there are applications still <e>writing</e> to the previous database, it's
171
If there are applications still <e>writing</e> to the previous database, it's
159
possible to setup a "Replication" relationship between the two databases,
172
possible to setup a "Replication" relationship between the two databases.
160
however this will not be covered here.
173
However, this document will not be cover that procedure.
161
</note>
174
</note>
162
175
163
</body>
176
</body>
Lines 166-192 Link Here
166
179
167
180
168
<chapter>
181
<chapter>
169
<title>Switch to the new server</title>
182
<title>Migrating To The New Server</title>
170
<section>
183
<section>
171
<body>
184
<body>
172
185
173
<p>
186
<p>
174
If you need to be sure that applications are working with the newly installed
187
If you need to be sure that applications are working with the newly installed
175
server, please test them against it, quite every application has configuration
188
server, please test them against it. Quite often every application has 
176
settings to chose which port or socket to use to connect to the database
189
configuration settings to chose which port or socket to use for connecting to
177
server. Simply start the server on an alternate port (for example 3307) and tell
190
the database server. Simply start the server on an alternate port (for example
178
your application or a test copy of it to connect with those parameters. Pay
191
3307) and tell your application, or a test copy of it, to connect with those 
179
attention that most of them will try to use the parameters found in the
192
parameters. Please note that most applications will try to use the parameters
180
<c>[client]</c> section of <path>/etc/mysql/my.cnf</path> config file.
193
found in the <c>[client]</c> section of <path>/etc/mysql/my.cnf</path> config file.
181
</p>
194
</p>
182
195
183
<p>
196
<p>
184
When you're satisfied with the results, remove every testing setting, stop the
197
When you're satisfied with the results, remove every test setting, stop the
185
old server and start the new one. Also make it the server that will start at
198
old server and start the new one. Also, be sure to add
186
next reboot.
199
<path>/etc/init.d/mysql</path> to the default runlevel, ensuring it starts at
200
the next reboot.
187
</p>
201
</p>
188
202
189
<pre caption="Use the new server">
203
<pre caption="Using the new server">
190
# <i>rc-update del mysql default</i>
204
# <i>rc-update del mysql default</i>
191
# <i>rc-update add mysql-500 default</i>
205
# <i>rc-update add mysql-500 default</i>
192
# <i>/etc/init.d/mysql stop</i>
206
# <i>/etc/init.d/mysql stop</i>
Lines 195-204 Link Here
195
209
196
<p>
210
<p>
197
Unmerge the old version, and make the new one the default. The unmerge command
211
Unmerge the old version, and make the new one the default. The unmerge command
198
will be unable to remove some files, the ones moved in <uri
212
will be unable to remove some files, such as the ones moved in <uri
199
link="#install_the_new_version">Backup old package and prepare
213
link="#install_the_new_version">Backing up the older version and preparing the
200
installation</uri>. This is an intended behavior, and avoid breaking application
214
installation</uri>. This is an intended behavior, and meant to avoid breaking
201
linked to the old MySQL version.
215
applications linked to the old MySQL version.
202
</p>
216
</p>
203
217
204
<pre caption="cleanup first step">
218
<pre caption="cleanup first step">
Lines 207-216 Link Here
207
# <i>cd /etc</i>
221
# <i>cd /etc</i>
208
# <i>mv mysql mysql.$(date +%F_%H-%M)</i>
222
# <i>mv mysql mysql.$(date +%F_%H-%M)</i>
209
# <i>rm -rf /usr/lib/*.TMP</i>
223
# <i>rm -rf /usr/lib/*.TMP</i>
210
# <i>rm -rf /usr/lib/*.TMP</i>
211
# <i>for i in /usr/lib/*mysql* ; do</i>
224
# <i>for i in /usr/lib/*mysql* ; do</i>
212
  <i>  readlink -f $i || [[ -L $i ]] &amp;&amp; rm $i</i>
225
  <i>  [[ -z "$( readlink -f $i )" ]] &amp;&amp; [[ -L $i ]] &amp;&amp; rm $i</i>
213
  <i>done</i>
226
  <i>done</i>
227
  <comment>(emerge app-admin/eselect-mysql if you haven't already)</comment>
214
# <i>eselect mysql list</i>
228
# <i>eselect mysql list</i>
215
# <i>eselect mysql set 1</i>
229
# <i>eselect mysql set 1</i>
216
# <i>eselect mysql show</i>
230
# <i>eselect mysql show</i>
Lines 222-235 Link Here
222
236
223
237
224
<chapter>
238
<chapter>
225
<title>Rebuild applications</title>
239
<title>Rebuilding Applications</title>
226
<section>
240
<section>
227
<body>
241
<body>
228
242
229
<p>
243
<p>
230
After you got rid of your old MySQL installation, you can now install the new
244
After you remove your old MySQL installation, you can now install the new
231
version. Note that <c>revdep-rebuild</c> from the <c>app-portage/gentoolkit</c>
245
version. Note that <c>revdep-rebuild</c> from the <c>app-portage/gentoolkit</c>
232
is necessary for rebuilding packages linking against MySQL.
246
is necessary for rebuilding packages linked against MySQL.
233
</p>
247
</p>
234
248
235
<pre caption="Reverse dependancies rebuild">
249
<pre caption="Reverse dependancies rebuild">
Lines 238-245 Link Here
238
</pre>
252
</pre>
239
253
240
<note>
254
<note>
241
Depending on which really is the old version <path>libmysqlclient.so</path>
255
Depending on the older MySQL version, the <path>libmysqlclient.so</path>
242
number may be 10, 12, 14 or 15, chose the one of the <e>old</e> package.
256
version may be 10, 12, 14 or 15. Please choose version of the <e>old</e>
257
package.
243
</note>
258
</note>
244
259
245
</body>
260
</body>
Lines 248-273 Link Here
248
263
249
264
250
<chapter>
265
<chapter>
251
<title>Final touches</title>
266
<title>Final Touches</title>
252
<section>
267
<section>
253
<body>
268
<body>
254
269
255
<pre caption="Upgrading user database">
270
<pre caption="Upgrading user database">
271
<comment>(Replace all instances of 'your_password' with your MySQL root password)</comment>
256
# <i>mysql_fix_privilege_tables-500 \</i>
272
# <i>mysql_fix_privilege_tables-500 \</i>
257
     <i>--defaults-file=/etc/mysql-500/my.cnf \</i>
273
     <i>--defaults-file=/etc/mysql-500/my.cnf \</i>
258
     <i>--user=root \</i>
274
     <i>--user=root \</i>
259
     <i>--password=</i><comment>'your_password'</comment><i></i>
275
     <i>--password='your_password'</i>
260
# <i>mysql -uroot -p</i><comment>'your_password'</comment><i> mysql -e "FLUSH PRIVILEGES;"</i>
276
# <i>mysql -uroot -p'your_password' mysql -e "FLUSH PRIVILEGES;"</i>
261
# <i>for tbl in $( mysql --silent -uroot -p</i><comment>'your_password'</comment><i> -e 'USE mysql ; SHOW TABLES LIKE "help%";' )</i>
277
# <i>for tbl in $( mysql --silent -uroot -p'your_password' -e 'USE mysql ; SHOW TABLES LIKE "help%";' )</i>
262
  <i>do</i>
278
  <i>do</i>
263
    <i>mysql -uroot -p</i><comment>'your_password'</comment><i> -e "use mysql ; TRUNCATE TABLE ${tbl};"</i>
279
    <i>mysql -uroot -p'your_password' -e "use mysql ; TRUNCATE TABLE ${tbl};"</i>
264
  <i>done</i>
280
  <i>done</i>
265
# <i>mysql -uroot -p</i><comment>'your_password'</comment><i> mysql &lt; /usr/share/mysql/fill_help_tables.sql</i>
281
# <i>mysql -uroot -p'your_password' mysql &lt; /usr/share/mysql/fill_help_tables.sql</i>
266
</pre>
282
</pre>
267
283
268
<p>
284
<p>
269
If you encountered any problems during the upgrade process, please report them
285
If you encounter any problems during the upgrade process, please report them
270
at our <uri link="https://bugs.gentoo.org">Bugzilla</uri>.
286
to our <uri link="https://bugs.gentoo.org">Bugzilla</uri>.
271
</p>
287
</p>
272
288
273
</body>
289
</body>

Return to bug 120210