对于任何的非系统软件的安装,本人都是比较推荐非root权限安装的。
所以虽然ubuntu的apt包管理机制很方便,但是对于大部分软件,特别是开发软件最好还是通过源码安装,方便修改安装。
下面是在Ubuntu下面非root安装mysql-server的步骤:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| sudo apt-get install cmake libncurses5-dev
apt-get source mysql-server
cd mysql-x.x.xx
cmake -DCMAKE_INSTALL_PREFIX=~/local/mysql -DMYSQL_DATADIR=~/local/mysql/data -DSYSCONFDIR=~/local/mysql/etc -DCURSES_LIBRARY=/usr/lib/libncurses.so -DCURSES_INCLUDE_PATH=/usr/include
cmake -DCMAKE_INSTALL_PREFIX=~/local/mysql -DMYSQL_DATADIR=~/local/mysql/data -DSYSCONFDIR=~/local/mysql/etc -DCURSES_INCLUDE_PATH=/usr/include -DCURSES_LIBRARY=/usr/lib/x86_64-linux-gnu/libncurses.so
make
make install
cd ~/local/mysql
mkdir etc cp support-files/my-medium.cnf etc/my.cnf
|
对my.cnf进行如下修改:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| [client] #password = your_password port = 3306
#这里是需要修改的地方 socket = /home/seiya/local/mysql/mysql.sock
[mysqld] port = 3306 skip-external-locking key_buffer_size = 16M max_allowed_packet = 1M table_open_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M
#这里是需要修改的地方 log-error=/home/seiya/local/mysql/log/error.log pid-file=/home/seiya/local/mysql/mysql.pid socket = /home/seiya/local/mysql/mysql.sock
|
一般最重要的是对端口的修改。
- 同时如果之前安装过mysql-server,一定要将所有的地方的.cnf文件清楚。否则启动时会优先使用之前的cnf。
最后安装MYSQL。
1 2 3 4 5 6 7 8 9 10 11 12
|
scripts/mysql_install_db --user=$USER --basedir=. --datadir=data --no-defaults
bin/mysqld_safe &
bin/mysql -uroot
bin/mysqladmin -u root password 'newpassword'
|
安照上面的步骤这样mysql就安装完成了