第一次在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) |
里面有个安装说明文件: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>
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安装版本,官网
Linux - Generic 2.6 (x86, 64-bit), Compressed TAR Archive | 5.5.20 | 177.3M | ||
(mysql-5.5.20-linux2.6-x86_64.tar.gz) |