yum install -y cmake bison bison-devel libaio-devel gcc gcc-c++ git ncurses-devel
下载mysql:
1.解压包tar -zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gzmv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysqluseradd -s /sbin/nologin mysqlmkdir /mnt/mysql_datamkdir /var/log/mysqlchown -R mysql:mysql /var/log/mysqlchown -R mysql:mysql /mnt/mysql_data4.初始化数据和指定安装目录和数据目录/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/mnt/mysql_data/6复制启动文件cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqld7.修改启动路径vi /etc/init.d/mysqldbasedir=/usr/local/mysqldatadir=/mnt/mysql_data8.增加环境变量 (最下面添加)vi /etc/profileexport PATH=$PATH:/usr/local/mysql/bin9.刷新配置文件source /etc/profile修改配置文件vi /etc/my.cnf[client]port = 3306[mysqld]basedir = /usr/local/mysqldatadir = /mnt/mysql_datasocket = /var/lib/mysql/mysql.socklog-error = /var/log/mysql/error.logpid-file = /mnt/mysql_data/mysql.pidmax_connections = 300character-set-server = utf8default-storage-engine = INNODBlower_case_table_names = 1max_allowed_packet = 16Muser = mysqltmpdir = /tmpsql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
11.添加开启自启
chown -R mysql:mysql /var/lib/mysql/chkconfig --add mysqldchkconfig mysqld onservice mysqld startnetstat -anpt13.修改root默认密码并授权远程访问:在/etc/my.cnf 最后增加: skip-grant-tables = 1重启MySQL: /etc/rc.d/init.d/mysqld restartmysql -uroot -puse mysqlupdate user set authentication_string = password('123456'), password_expired = 'N', password_last_changed = now() where user = 'root';update user set host='%' where user='root';flush privileges;删除/etc/my.cnf文件中的 skip-grant-tables = 1重启MySQL: /etc/rc.d/init.d/mysqld restart
暂时关闭防火墙测试远程连接:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动systemctl status iptables