wget http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-5.5/mysql-5.5.20-linux2.6-x86_64.tar.gz
传到内网服务器
scp mysql-5.5.20-linux2.6-x86_64.tar.gz root@10.0.20.11:/root
ssh 10.0.20.11
tar -zxvf mysql-5.5.20-linux2.6-x86_64.tar.gz
mv ./mysql-5.5.20-linux2.6-x86_64 /usr/local/mysql
groupadd mysql
useradd -r -g mysql mysql
cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .
/usr/local/mysql/scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
cp support-files/my-medium.cnf /etc/my.cnf
cp ./bin/mysql /usr/bin/
cp support-files/mysql.server /etc/init.d/mysql
sudo /etc/init.d/mysql start
./bin/mysqladmin -u root password 'pwd'
/etc/init.d/mysql restart
mysql -uroot -p
GRANT ALL PRIVILEGES ON *.* TO root@10.0.20.12 IDENTIFIED BY 'pwd';
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'pwd';
FLUSH PRIVILEGES;
//自启动
chkconfig --level 345 mysql on
Mysql默认目录修改
1、停止服务器
/etc/init.d/mysql stop
2、复制数据库到新目录
mkdir -p /data/mysql/
cp -RP /usr/local/mysql/data /data/mysql/
chown -R mysql /data/mysql/data
3、修改MySQL启动脚本/etc/init.d/mysql
修改MySQL启动脚本/etc/init.d/mysql,把其中datadir=/var/lib/mysql一行中,等号右边的路径改成你现在的实际存放路径:/data/mysql/data。
$ vi /etc/init.d/mysql
#datadir= (注释此行)
datadir=/data/mysql/data (加上此行)
或下载,修改完毕后上传
2、重新启动MySQL服务
/etc/init.d/mysql start