mysql 5.1.73安装

Mysql安装包下载地址:https://downloads.mysql.com/archives/community/

一 安装

1.1 建用户

groupadd mysql

useradd -g mysql mysql 

passwd mysql

1.2 安装依赖包

yum install libaio -y

yum install -y numactl 

1.3 解压

tar -xvf mysql-5.1.73-linux-x86_64-glibc23.tar.gz

cp mysql-5.1.73-linux-x86_64-glibc23  /usr/local/mysql -r

chown -R mysql:mysql /usr/local/mysql

1.4 新建目录

mkdir -p /data/server/mysql/data

mkdir -p /data/server/mysql/binlog

chown -R mysql:mysql /data/server/mysql/

1.5 新建配置文件

cd /etc

mv my.cnf my.cnf_bak

[root@rac1 etc]# cat my.cnf

[mysqld]

basedir=/usr/local/mysql/

datadir=/data/server/mysql/data

log-bin=/data/server/mysql/binlog/mysql-bin

log-bin-index=/data/server/mysql/binlog/binlog.index

server-id=1

port=3306

socket=/tmp/mysql.sock

user=mysql

# Disabling symbolic-links is recommendedto prevent assorted security risks

symbolic-links=0



[mysqld_safe]

log-error=/data/server/mysql/mysqld.err

pid-file=/data/server/mysql/mysqld.pid

1.6 建立基本库

/usr/local/mysql/scripts/mysql_install_db --user=mysql  --basedir=/usr/local/mysql --datadir=/data/server/mysql/data --defaults-file=/etc/my.cnf

Installing MySQL system tables...

OK

Filling help tables...

OK



To start mysqld at boot time you have to copy

support-files/mysql.server to the right place for your system



PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:



/usr/local/mysql/bin/mysqladmin -u root password 'new-password'

/usr/local/mysql/bin/mysqladmin -u root -h rac1 password 'new-password'



Alternatively you can run:

/usr/local/mysql/bin/mysql_secure_installation



which will also give you the option of removing the test

databases and anonymous user created by default.  This is

strongly recommended for production servers.



See the manual for more instructions.



You can start the MySQL daemon with:

cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &



You can test the MySQL daemon with mysql-test-run.pl

cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl



Please report any problems with the /usr/local/mysql/scripts/mysqlbug script!

1.7 配置环境变量

vi /root/.bash_profile

在PATH=$PATH:$HOME/bin后添加:/usr/local/mysql/bin

source /root/.bash_profile

1.8 启动数据库

mysqld_safe --defaults-file=/etc/my.cnf &

1.9 修改root密码

mysqladmin -u root -p password 新密码

1.10 设置mysql开机自启

cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql

chkconfig --add mysql 

chkconfig mysql on

 

vi /etc/rc.d/init.d/mysql

将datadir=修改为datadir=/data/server/mysql/data

 

猜你喜欢

转载自blog.csdn.net/yabignshi/article/details/114281912