进入/usr/local
#cd /usr/local
下载
#wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.39-linux2.6-x86_64.tar.gz
#解压
tar zxvf mysql-5.5.39-linux2.6-x86_64.tar.gz
#软链
ln -s mysql-5.5.39-linux2.6-x86_64 mysql
cd mysql
#授权
groupadd mysql useradd -g mysql mysql chown -R mysql . chgrp -R mysql .
用mysql_install_db创建MySQL授权表初始化
scripts/mysql_install_db --user=mysql
chown -R mysql data
复制配置文件至etc
#cp /usr/local/mysql/support-files/my-huge.cnf /etc/my.cnf
启动
#bin/mysqld_safe --user=mysql &
### 启动时如果报了 mysqld_safe mysqld from pid file /usr/local/mysql/data/XXXX.pid ended
解决方案是:在配置文件中加入
user=root
datadir=/usr/local/mysql/data
[mysqld]
user =root
port = 3306
socket = /tmp/mysql.sock
datadir=/usr/local/mysql/data
### Starting mysqld daemon with databases from /usr/local/mysql/var 表示正常启动
注:如果任然报这个错 重新执行一下
#scripts/mysql_install_db --user=mysql
设置root密码。默认安装密码为空
#/usr/local/mysql/bin/mysqladmin -uroot password yourpassword
拷贝编译目录的一个脚本,设置开机自动启动
cp support-files/mysql.server /etc/rc.d/init.d/mysqld chmod 700 /etc/init.d/mysqld chkconfig --add mysqld chkconfig --level 345 mysqld on
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
启动mysqld服务
#service mysqld start
查看3306端口是否打开。要注意在防火墙中开放该端口
#netstat -atln