卸载已经安装过的旧版本mysql
1 2 3 | rpm -e mysql rpm -e --nodeps mysql yum remove mysql |
groupadd mysql mkdir -pv /data/mysqldb useradd -r -g mysql -d /data/mysqldb -s /sbin/nologin mysql
安装MySql
安装mysql依赖包
1 | yum -y install make gcc* cmake bison-devel ncurses-devel |
下载mysql5.6.33
网址http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/
1 2 3 | wget http: //ftp .ntu.edu.tw /MySQL/Downloads/MySQL-5 .6 /mysql-5 .6.33. tar .gz tar -zxvf mysql-5.6.33. tar .gz cd mysql-5.6.33 |
编译安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | cmake \ -DCMAKE_INSTALL_PREFIX= /usr/local/mysql \ -DMYSQL_DATADIR= /data/mysqldb \ -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 make && make install |
配置mysql
1 2 3 4 | chown -R mysql:mysql /usr/local/mysql mkdir -p /data/mysqldb chown -R mysql:mysql /data mv /etc/my .cnf /etc/my .bak |
初始化mysql
1 2 | cd /usr/local/mysql scripts /mysql_install_db --basedir= /usr/local/mysql --datadir= /data/mysqldb --user=mysql |
启动mysql
1 2 3 | cp support-files /mysql .server /etc/init .d /mysqld chkconfig mysqld on service mysqld start |
mysql环境变量配置
1 2 3 | PATH= /usr/local/mysql/bin :$PATH export PATH source /etc/profile |
设置root登录口令
1 2 | mysql -uroot mysql> SET PASSWORD = PASSWORD( '123456' ); |