unbuntu10.04升级mysql5.1到5.5

参考:

http://blog.csdn.net/lanphaday/article/details/6298283

http://blog.shanbay.com/archives/937

 

1.下载二进制安装包[5.5.24]

写道
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.24-linux2.6-i686.tar.gz/from/http://mysql.spd.co.il/

注意要下载 .tar.gz那个版本, tar版本很坑爹,解压后都是rpm文件,在最最下面

 

2.备份

$ mkdir /root/mysql-5.1-conf  
$ cp -R /etc/mysql/ /root/mysql-5.1-conf

$ mkdir /root/mysql-5.1-data 
$ cp -R /var/lib/mysql/ /root/mysql-5.1-data

$ mkdir /root/mysql-5.1-dump  
$ mysqldump -uuser_name -p --databases mysql > /root/mysql-5.1-dump/mysql.sql
$ mysqldump -uuser_name -p --databases db_name > /root/mysql-5.1-dump/db_name.sql

** user_name 我知道是啥意思,我用的root来做的dump
** 第一个dump是备份的mysql表
** 第二个dump是备份你的数据表,结果我就是备份的db_name,这些写文档的人太不厚道了,多写一句话注释一下啥.害我没有备份数据表.

*最后一个备份需要放开/root/mysql-5.1-dump文件夹的权限

 

3.安装异步I/O库

$ apt-get install libaio-dev

Mysql 5.5 的新的 Inno DB 使用了 libaio 来增进性能

 

4.解包并将解包的 mysql 目录放到安装目录

$ tar xzvf mysql-5.5.24-linux2.6-i686.tar.gz

$ cp -R mysql-5.5.24-linux2.6-i686 /usr/local/
$ cd /usr/local/
$ ln -s mysql-5.5.24-linux2.6-i686 mysql

 

5.删除旧版本的mysql

$ apt-get remove mysql-server-5.1
$ apt-get autoremove
$ apt-get remove mysql-client
$ apt-get autoremove

 

6.把 mysql bin 目录加到 PATH 环境变量

$ vim /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/mysql/bin"

 

7.为 mysql 安装目录和文件设定正确的权限

$ cd /usr/local/mysql
$ chown -R mysql:mysql data

 

8.创建 socket 目录,并设置权限

$ mkdir /var/run/mysqld/
$ chown -R mysql:mysql /var/run/mysqld/

 

9.把 mysql 的 sample 配置拷贝到 etc 目录,并设置好路径

$ cd /usr/local/mysql/support-files/
$ cp my-large.cnf /etc/my.cnf

编辑/etc/my.cnf的内容
user = mysql
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
tmpdir = /tmp
log_error = /var/log/mysql/error.log

[client]
#password       = your_password
port            = 3306
#socket         = /tmp/mysql.sock
socket          = /var/run/mysqld/mysqld.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
user            = mysql
port            = 3306
#socket         = /tmp/mysql.sock
socket          = /var/run/mysqld/mysqld.sock
basedir         = /usr/local/mysql
datadir         = /usr/local/mysql/data
tmpdir          = /tmp
log_error       = /var/log/mysql/error.log

 

10.把 mysql server 的启动脚本拷贝到启动目录

$ cd /usr/local/mysql/support-files/
$ cp mysql.server /etc/init.d/mysql
$ chmod +x /etc/init.d/mysql
$ update-rc.d mysql defaults

 

11.删除旧版的 mysql 文件

$ rm -R /var/lib/mysql
$ rm -R /etc/mysql
$ rm -R /usr/lib/mysql

 

在安装后第一次使用 mysql server 时切记要跳过 grants 表,原因有二:一是我们可能希望原来的用户和权限数据,二是新版的 grants 表结构有所变化。

 

12.无 grants 表启动 mysql

写道
这里要以root权限运行
sudo su
# /usr/local/mysql/bin/mysqld --skip-grant-tables --user=mysql

出现错误:
120530 11:28:09 [Warning] Can't create test file /var/lib/mysql/xiaofei-desktop.lower-test
120530 11:28:09 [Warning] Can't create test file /var/lib/mysql/xiaofei-desktop.lower-test
mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 2)
120530 11:28:09 [ERROR] Aborting

120530 11:28:09 [Note] mysqld: Shutdown complete


不知怎么的又不出错了。不过在这里卡了很久,运行之后一直没有反应,好像是要什么东西一直没有运行完,其实不是,这个时候表示跳过grant表启动了。
直接进入下一步

 

13.从备份中装载 mysql 用户和权限数据

$ cd /root/mysql-5.1-dump/
$ mysql < mysql.sql

 

14.开一个新的终端

sudo /usr/local/mysql/bin/mysql_upgrade
写道
我的效果:
xiaofei@xiaofei-desktop:/root/mysql-5.1-dump$ mysql_upgrade
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/var/run/mysqld/mysqld.sock'
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/var/run/mysqld/mysqld.sock'
mysql.columns_priv OK
mysql.db OK
mysql.event OK
mysql.func OK
mysql.general_log OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.ndb_binlog_index OK
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
mysql.proxies_priv OK
mysql.servers OK
mysql.slow_log OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
performance_schema.cond_instances OK
performance_schema.events_waits_current OK
performance_schema.events_waits_history OK
performance_schema.events_waits_history_long OK
performance_schema.events_waits_summary_by_instance OK
performance_schema.events_waits_summary_by_thread_by_event_name OK
performance_schema.events_waits_summary_global_by_event_name OK
performance_schema.file_instances OK
performance_schema.file_summary_by_event_name OK
performance_schema.file_summary_by_instance OK
performance_schema.mutex_instances OK
performance_schema.performance_timers OK
performance_schema.rwlock_instances OK
performance_schema.setup_consumers OK
performance_schema.setup_instruments OK
performance_schema.setup_timers OK
performance_schema.threads OK
Running 'mysql_fix_privilege_tables'...
ERROR 1064 (42000) at line 47: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(14), Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant'' at line 1
ERROR 1064 (42000) at line 49: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(14), Column_priv set('Select','Insert','Update','References') COLLATE utf8_gene' at line 1
ERROR 1064 (42000) at line 81: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor' at line 1
ERROR 1064 (42000) at line 483: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(14) AFTER Proc_priv' at line 2
FATAL ERROR: Upgrade failed


又出错啦...明天搞

iaofei@xiaofei-desktop:~$ sudo /usr/local/mysql/bin/mysql_upgrade
[sudo] password for xiaofei:
Looking for 'mysql' as: /usr/local/mysql/bin/mysql
Looking for 'mysqlcheck' as: /usr/local/mysql/bin/mysqlcheck
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/var/run/mysqld/mysqld.sock'
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/var/run/mysqld/mysqld.sock'
mysql.columns_priv OK
mysql.db OK
mysql.event OK
mysql.func OK
mysql.general_log OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.ndb_binlog_index OK
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
mysql.proxies_priv OK
mysql.servers OK
mysql.slow_log OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Running 'mysql_fix_privilege_tables'...
OK

今天运行就是这样?只是把机器重启了一次?

 

15.kill 掉 12步启动的mysql时程

写道
sudo kill ????

sudo /etc/init.d/mysql start 成功

mysql> status;
--------------
mysql Ver 14.14 Distrib 5.1.62, for debian-linux-gnu (i486) using readline 6.1

Connection id: 1
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.5.24-log MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /var/run/mysqld/mysqld.sock
Uptime: 28 sec

Threads: 1 Questions: 4 Slow queries:

 

16.恢复数据表.

写道
先前没有通过dump来备份表,但好歹有备份了文件夹.

xiaofei@xiaofei-desktop:/root/mysql-5.1-data/mysql$ ls
bom djangocms ib_logfile0 icgoo mysql_upgrade_info phpmyadmin xiaofei-desktop.pid xiaofei_icgoo xiaofei_wit
debian-5.1.flag ibdata1 ib_logfile1 mysql onlinestore test11 xiaofei_ecgoo xiaofei_newecgoo zhidao
xiaofei@xiaofei-desktop:/root/mysql-5.1-data/mysql$ sudo cp -R * /usr/local/mysql/data
[sudo] password for xiaofei:
xiaofei@xiaofei-desktop:/root/mysql-5.1-data/mysql$

xiaofei@xiaofei-desktop:/usr/local/mysql/data$ ls
bom ib_logfile0 mysql-bin.000001 mysql-bin.000005 mysql-bin.000009 onlinestore test11 xiaofei_newecgoo
debian-5.1.flag ib_logfile1 mysql-bin.000002 mysql-bin.000006 mysql-bin.000010 performance_schema xiaofei-desktop.pid xiaofei_wit
djangocms icgoo mysql-bin.000003 mysql-bin.000007 mysql-bin.index phpmyadmin xiaofei_ecgoo zhidao
ibdata1 mysql mysql-bin.000004 mysql-bin.000008 mysql_upgrade_info test xiaofei_icgoo

 

 

你可能感兴趣的:(mysql5)