ubuntu10.10,下载mysql源码,编译安装

第一次在linux上安装mysql,还是费了一些周折,总算基本理清思路了。

先说说我最终成功安装的步骤,即:下载mysql源码,编译安装 

 当前mysql版本是5.5.20,我的系统版本是ubuntu 10.10

1下载源码:

     在官方网站,       选择:MySQL Community Server--download     选择 sourcecode,前面几个都是什么rpm,最后一个是我觉得应该下载的包:

Generic Linux (Architecture Independent), Compressed TAR Archive
5.5.20 23.2M
(mysql-5.5.20.tar.gz)
2下载完成,解压缩。

里面有个安装说明文件:INSTALL-SOURCE

打开,里面这一段是核心安装步骤:(命令前都加sudo执行!)

# Preconfiguration setup     首先是添加一个用户组
shell> groupadd mysql
shell> useradd -r -g mysql mysql
# Beginning of source-build specific instructions
shell> tar zxvf mysql-VERSION.tar.gz         解压缩源码包
shell> cd mysql-VERSION                          切换到源码包目录
shell> cmake .                                            执行cmake,产生mk文件(没有cmake,sudo apt-get install cmake)
shell> make                                                 编辑
shell> make install                                       安装
# End of source-build specific instructions             -----------ok,安装完成了哦
# Postinstallation setup                                ----下面是配置mysql
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql     ---执行内部mysql安装(参看红线下方执行结果
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional                           --字面意思:下面这个命令可选
shell> cp support-files/my-medium.cnf /etc/my.cnf    复制mysql配置文件
shell> bin/mysqld_safe --user=mysql &                启动数据库
# Next command is optional                          --字面意思:下面这个命令可选
shell> cp support-files/mysql.server /etc/init.d/mysql.server   设置自启动


按照这个就能完整安装了

3安装完并且配置完,进去看一下

在/usr/local/mysql 目录,执行

root@cheng-laptop:/usr/local/mysql#  ./bin/mysql -u root -S /tmp/mysql.sock -p

正常登录,提示:

Server version: 5.5.20-log Source distribution

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

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql>

4官方网站有个gui工具,可以下载试一下:

MySQL Workbench (GUI Tool)

5其他就是创建链接或者环境变量,实现在终端中,直接执行mysql........

这个网上很多,自己搜集吧

-------------------------------------------------------------------------------------------------------------

执行内部mysql安装结果)

cheng@cheng-laptop:/usr/local/mysql$ sudo scripts/mysql_install_db --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

(要设置开机自启动,请将文件复制到系统正确的地方)
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
(记得给mysql管理员设置密码)
To do so, start the server, then issue the following commands:(设置密码方式1)
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h cheng-laptop password 'new-password'
Alternatively you can run:(或者你可以运行下面这个命令进行密码设置,我用的这个,里面其实不只是设置root密码)
./bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:(运行MySQL daemon,需要cd到当前目录,执行./bin/mysqld_safe &)
cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbug script!
cheng@cheng-laptop:/usr/local/mysql$ 

------------------------------------------------------------------------------------------------------

其他:

1关于ubuntu安装版本,官网

这里有*.deb安装包
A:ubuntu是Debain发展来的,应该是可以安装的,至于是Debain 5还是Debain 6,我就说不清了。
B:我的ubuntu 10.10发行的时候,还没有Debain 6,所以我应该是Debain 5。
C:当初尝试的时候,Debain 6,Debain 5我都安装过,安装没有报错,因为在系统菜单中没有发现mysql快捷方式,以为没有安装成功,现在想想应该是安装成功了,只是我没有进行配置,配置一下应该能用。

》》》》》》》还有一个版本应该也可以用:
2 常见错误解决:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
刚开始的时候,被这个错误搞晕了,其实就是“连接文件”目录不对应,mysqld.sock是一个连接配置文件
我看了一下我的文件在“/tmp/mysql.sock”
所以用-S指定连接文件就ok了
   ./bin/mysql -u root -S /tmp/mysql.sock -p



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值