ubuntu mysql源码安装

在ubuntu下安装mysql可以直接sudo apt-get install mysql

源码安装可以自由点,自定一些自己的设定

1,下载最新的mysql5.1.66

 http://cdn.mysql.com/Downloads/MySQL-5.1/mysql-5.1.66.tar.gz

2,config

./configure --prefix=/usr/local/mysql/ \

--enable-assembler\

--with-charset=utf8\

--with-extra-charsets=complex\

--enable-thread-safe-client\

--with-big-tables\

--with-readline\

--with-ssl\

--with-embedded-server\

--enable-local-infile\

--with-plugins=partition,innobase,myisammrg

 

遇到没有error: No curses/termcap library found

sudo apt-get install libncurses5 libncurses5-dev

3,sudo make

遇到 exec: g++: not found

sudo apt-get install gobjc++

继续make还是报错,重新config,sudo make 一切ok

4,sudo make install


5,新建mysql用户组和用户

sudo /usr/sbin/groupadd mysql

sudo /usr/sbin/useradd -g mysql mysql

6,初始化mysql db

sudo /usr/local/mysql/bin/mysql_install --user=mysql

//初始化结果代码

Installing MySQL system tables...
121011 15:52:46 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK
Filling help tables...
121011 15:52:48 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
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 !
To do so, start the server, then issue the following commands:

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h X220 password 'new-password'

Alternatively you can run:
/usr/local/mysql/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:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/mysql/bin/mysqlbug script!

7,拷贝mysql.server和my.cnf

sudo cp mysql-5.1.66/support-files/my-medium.cnf /etc/my.cnf

sudo cp mysql-5.1.66/support-files/mysql.server /etc/init.d/mysql.server

8,修改mysql.server权限

sudo chmod 755 /etc/init.d/mysql.server

9,启动mysql

sudo /etc/init.d/mysql.server start

检测是否启动 

ps aux|grep mysql

root     12872  0.0  0.0   2236   596 pts/2    S    16:12   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/var --pid-file=/usr/local/mysql/var/X220.pid
mysql    12974  0.1  0.3 113352 16020 pts/2    Sl   16:12   0:00 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --user=mysql --log-error=/usr/local/mysql/var/X220.err --pid-file=/usr/local/mysql/var/X220.pid --socket=/tmp/mysql.sock --port=3306

charles  12995  0.0  0.0   4388   832 pts/2    S+   16:14   0:00 grep --color=auto mysql 

已经启动

编译安装完成

修改/usr/local/mysql/var(mysql数据库的datadir)的权限

sudo chown -R mysql:mysql /usr/local/mysql/var


剩下的事情就是根据需求修改mysql.cnf 

以后再说

posted on 2012-10-11 16:18  charles小白  阅读(398)  评论(0)    收藏  举报