#准备工作
# sudo apt-get install -y cmake build-essential libncurses5-dev bison wget vimsysv-rc-conf
# sudo groupadd mysql
# sudo useradd -r -g mysql mysql
# sudo mkdir -p /data/mysql
# sudo mkdir -p /usr/local/mysql
# sudo mkdir -p /usr/software
# cd /usr/software
# sudo wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.28.tar.gz
# sudo tar zxvf mysql-5.5.28.tar.gz
# cd mysql-5.5.28
# sudo cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data/mysql/ \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
# sudo make
# sudo make install
#设置目录权限
# sudo chown -R mysql /usr/local/mysql
# sudo chgrp -R mysql /usr/local/mysql
# sudo chown -R mysql /data/mysql
# sudo chgrp -R mysql /data/mysql
#初始化
# cd /usr/local/mysql
# sudo scripts/mysql_install_db \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/data/mysql/ \
--no-defaults
# sudo cp support-files/my-medium.cnf /etc/my.cnf
# sudo vim /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql
user=mysql
:wq
# sudo cp support-files/mysql.server /etc/init.d/mysql
# sudo support-files/mysql.server start
#设置用户
# sudo /usr/local/mysql/bin/mysqladmin -u root password 'yourpassword'
# sudo /usr/local/mysql/bin/mysql -u root -p
mysql> use mysql;
mysql> delete from user where password='';
mysql> flush privileges;
mysql> grant all privileges on *.* to youruser@'%' identified by "yourpassword";
mysql> flush privileges;
mysql> select User,Password,Host from user;
mysql> exit;
#加入开机启动
# sudo sysv-rc-conf
#找到mysql一栏,勾选3,4,5,按q退出
#至此,mysql-5.5.28编译安装完毕