准备工作
wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.40.tar.gz
卸载自带的mysql
rpm -qa|grep -i mariadb
rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
安装依赖包
yum install tree ncurses-devel libaio-devel gcc make cmake autoconf perl gcc-c++
创建mysql用户
useradd -s /sbin/nologin -M mysql
正式开始安装
tar -xzvf mysql-5.6.40.tar.gz
cd mysql-5.6.40
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6.40 \
-DMYSQL_DATADIR=/application/mysql-5.6.40/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.6.40/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_ZLIB=bundled \
-DWITH_SSL=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLE_DOWNLOADS=1 \
-DWITH_DEBUG=0
make
make install
完成
----
初始化
[root@localhost mysql]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql
将启动脚本放到/etc/init.d/里面
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
将配置文件放到/etc中
[root@localhost mysql]# cp /application/mysql/support-files/my-default.cnf /etc/my.cnf
创建tmp目录和修改权限配置
[root@localhost mysql]# mkdir /application/mysql/tmp
[root@localhost mysql]# chown -R mysql.mysql /application/mysql-5.6.40/
[root@localhost mysql]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS!
最后配置path变量
vi /etc/profile
add
export PATH=/application/mysql/bin:$PATH
source /etc/profile
--
修改密码
mysqladmin -uroot -p password
回车
新密码
确认新密码
------------
总结一下就是,先安装软件,然后进行初始化操作,然后配置path环境变量、mysqld启动命令、配置文件my.conf、通过mysqladmin修改密码,即可。