1 |
oh yeah, and change the --password='' field to your own password, dont just |
2 |
copy past. |
3 |
|
4 |
Dave |
5 |
|
6 |
On 10/22/05, Dave Strydom <strydom.dave@×××××.com> wrote: |
7 |
> |
8 |
> Man, this ...... page messed up my mysql stuff seriously, ok, for those |
9 |
> who had the same libmysqlclient.so.12 problems i had or for those people |
10 |
> who get to the importing of all your database backup and it stuffs up. here |
11 |
> is DAVE'S guide to upgrading to MySQL 4.1 |
12 |
> |
13 |
> |
14 |
> # = commands to type |
15 |
> = = comments |
16 |
> |
17 |
> ==================================== |
18 |
> # mkdir -p /home/backup/mysql |
19 |
> # nano mysql_backup.php |
20 |
> |
21 |
> == |
22 |
> = Place the code below into the mysql_backup.php and save the file = |
23 |
> == |
24 |
> |
25 |
> /*------mysql_backup.php---------*/ |
26 |
> <? |
27 |
> print("mysql backup\n"); |
28 |
> foreach (glob('/var/lib/mysql/*') as $fullname) |
29 |
> { |
30 |
> $database = basename($fullname); |
31 |
> $command = sprintf('mysqldump -a -B %s -c -v -Q > |
32 |
> /home/backup/mysql/%s.sql --password=\'Our@db$IG\'', $database, |
33 |
> $database); |
34 |
> |
35 |
> exec($command); |
36 |
> print($database . ' : ' . $command . "\n\n\n"); |
37 |
> |
38 |
> } |
39 |
> ?> |
40 |
> |
41 |
> |
42 |
> /*-----------------------------------------------------*/ |
43 |
> |
44 |
> # nano mysql_restore.php |
45 |
> |
46 |
> == |
47 |
> = Place the code below in the mysql_restore.php and save the file = |
48 |
> == |
49 |
> |
50 |
> /*------mysql_retore.php---------*/ |
51 |
> <? |
52 |
> |
53 |
> print("mysql backup\n"); |
54 |
> |
55 |
> $dir = '/home/backup/mysql/'; |
56 |
> if ($fp = opendir($dir)) |
57 |
> { |
58 |
> print('running...'); |
59 |
> while (($file = readdir($fp)) !== FALSE) { |
60 |
> echo "$file\n"; |
61 |
> |
62 |
> $database = basename($file); |
63 |
> $command = sprintf('mysql < /home/backup/mysql/%s --password=\'Our@db$IG\'', |
64 |
> $database); |
65 |
> print($database . ' : ' . $command . "\n\n\n"); |
66 |
> exec($command); |
67 |
> |
68 |
> } |
69 |
> closedir($fp); |
70 |
> } |
71 |
> else |
72 |
> { |
73 |
> print('cannot open path ' . $dir); |
74 |
> } |
75 |
> |
76 |
> ?> |
77 |
> |
78 |
> /*---------------*/ |
79 |
> |
80 |
> # php mysql_backup.php |
81 |
> |
82 |
> == |
83 |
> = This will make individual backup's of all your databases, the reason i |
84 |
> make it create scripts for each database |
85 |
> = instead of just pumping it all into 1 database, is because if there is a |
86 |
> problem on like 486590 of a 5 million |
87 |
> = line file, its going to be a bitch to work with, this way it just |
88 |
> simplifies matters |
89 |
> == |
90 |
> |
91 |
> # quickpkg dev-db/mysql |
92 |
> # /etc/init.d/mysql stop |
93 |
> # emerge -C mysql |
94 |
> # rm -rf /var/lib/mysql/ /var/log/mysql |
95 |
> # emerge mysql |
96 |
> # etc-update |
97 |
> # emerge --config =mysql-4.1.14 |
98 |
> # revdep-rebuild --soname libmysqlclient.so.12 |
99 |
> # php mysql_restore.php |
100 |
> # mysql_fix_privilege_tables --defaults-file=/etc/mysql/my.cnf --user=root |
101 |
> --password='PASSWORD' |
102 |
> # /etc/init.d/mysql restart |
103 |
> |
104 |
> And thats it. |
105 |
> ======================================= |
106 |
> |
107 |
> Dave |
108 |
> |