时间:2021-07-01 10:21:17 帮助过:29人阅读
环境 : Debian 6.02 (squeeze) x64
软件:MySQL 5.5.14
步骤:
1、升级系统
1 | #apt-get update |
2 |
3 | #apt-get upgrade |
4 |
5 | #apt-get install chkconfig libpcre3-dev build-essential libssl-dev libncurses5-dev bison |
2、准备软件
cmake-2.8.5、mysql 5.5.14
1 | #wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz |
2 |
3 | #wget ftp://mirror.anl.gov/pub/mysql/Downloads/MySQL-5.5/mysql-5.5.14.tar.gz |
3、安装
1)、安装 cmake
1 | #tar zxvf cmake-2.8.5.tar.gz |
2 |
3 | #cd cmake-2.8.5/ |
4 |
5 | #./configure |
6 |
7 | #make && make install |
2)、添加mysql用户
1 | groupadd mysql |
2 |
3 | useradd --shell /sbin/nologin -g mysql mysql |
3)、安装mysql
01 | #tar zxvf mysql-5.5.14.tar.gz |
02 |
03 | #cd mysql-5.5.14 |
04 |
05 | #cmake / |
06 |
07 | -DCMAKE_INSTALL_PREFIX=/usr/ local /mysql / |
08 |
09 | -DMYSQL_DATADIR=/usr/ local /data/mysql / |
10 |
11 | -DDEFAULT_CHARSET=utf8 / |
12 |
13 | -DDEFAULT_COLLATION=utf8_general_ci / |
14 |
15 | -DEXTRA_CHARSETS=all / |
16 |
17 | -DWITH_MYISAM_STORAGE_ENGINE=1 / |
18 |
19 | -DWITH_INNOBASE_STORAGE_ENGINE=1 / |
20 |
21 | -DWITH_READLINE=1 / |
22 |
23 | -DENABLED_LOCAL_INFILE=1 / |
24 |
25 | -DMYSQL_TCP_PORT=3306 |
26 |
27 | #make && make install |
4)、更改安装文件夹权限
1 | #chown -R mysql:mysql /usr/local/mysql/ |
2 |
3 | #chown -R mysql:mysql /usr/local/data/mysql |
5)、初始化话
1 | #sh scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/data/mysql --user=mysql |
6)、复制mysql配置文件,生成启动脚本
1 | #cp support-files/my-medium.cnf /etc/my.cnf |
2 |
3 | #cp support-files/mysql.server /etc/init.d/mysqld |
7)、设置自启动
1 | #chmod 755 /etc/init.d/mysqld |
2 |
3 | #chkconfig mysqld on |
8)、设置环境变量
1 | #nano /etc/profile |
加入以下内容
1 | export PATH=/usr/ local /mysql/bin:$PATH |
2 |
3 | alias mysql_start= "mysqld_safe &" |
4 |
5 | alias mysql_stop= "mysqladmin –u root -p shutdown" |
4、启动测试
1 | #service mysqld start |
2 |
3 | #/usr/local/mysql/bin/mysql -uroot –p |
5、密码及安全配置
1 | #/usr/mysql/bin/mysql_secure_installation |