操作系统:CentOSrelease 6.8 (Final)
虚拟机:VMware
数据库:mysql-5.5.53.tar.gz
注意事项:源码安装包mysql-5.5.32.tar.gz之后的版本安装方式发生了变化。
安装步骤如下:
#rpm -qa|grep mysql
#yum remove mysql*
#yum install cmake ncurses.x86_64 ncurses-devel.x86_64bison-devel
#grupadd mysql
#groupadd mysql
#useradd -g mysql mysql -s nologin
#mkdir -p application
#cd /application
application# mkdir mysql/data -p
#chmod -R 777 /mysql/data
#chmod -R 777 /mysql/data -p
#chmod -R 777 /mysql/data -f
#chown -R mysql:mysql /mysql
#chown -R mysql:mysql /mysql/data
#mkdir /var/lib/mysql
#chown -R mysql:mysql /var/lib/mysql
#rz #从终端上传到服务器
#tar xf mysql-5.5.53.tar.gz
[[email protected] mysql-5.5.53]#
cmake \
-DCMAKE_INSTALL_PREFIX=/application/mysql \
-DMYSQL_DATADIR=/application/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
[[email protected] mysql-5.5.53]#make && make install
[[email protected] support-files]# cp my-small.cnf /etc/my.cnf
[[email protected] scripts]# mysql_install_db \ #初始化数据库
> --basedir=/application/mysql \
> --datadir=/application/mysql/data \
> --user=mysql
配置mysql的环境变量:
#vim /etc/profile.d/mysql.sh
#export PATH=/usr/local/mysql/bin:$PATH
#source /etc/profile.d/mysql.sh 立即生效
启动MySQL
添加服务,拷贝服务脚本到init.d目录,并设置开机启动
#cp support-files/mysql.server /etc/init.d/mysqld
#chkconfig mysqld on
#chkconfig mysqld --level 2345 on
#service mysqld start
配置root用户
MySQL启动成功后,root默认没有密码,我们需要设置root密码
#mysql
mysql> SET PASSWORD = PASSWORD(‘*****‘);