1.先安装依赖,依赖要是安装失败会中断执行
yum install -y cmake make gcc gcc-c++ libaio ncurses ncurses-devel
2.然后就是 安装包 名字不一 样的替换一下就可以 mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz
#!/bin/bash cd /usr/local/src pwd tar -zxvf mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz cp -r mysql-5.7.30-linux-glibc2.12-x86_64 /usr/local/mysql groupadd mysql useradd -r -g mysql mysql cd /usr/local/mysql chown -R mysql:mysql ./ bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data chown -R mysql:mysql ./ chown -R mysql:mysql data echo " [mysqld] character_set_server=utf8 init_connect='SET NAMES utf8' basedir=/usr/local/mysql datadir=/usr/local/mysql/data socket=/tmp/mysql.sock #不区分大小写 lower_case_table_names = 1 #不开启sql严格模式 sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' log-error=/var/log/mysqld.log pid-file=/usr/local/mysql/data/mysqld.pid" > /etc/my.cnf cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld sed -i "s#basedir=#basedir=/usr/local/mysql#" /etc/init.d/mysqld sed -i "s#datadir=#datadir=/usr/local/mysql/data#" /etc/init.d/mysqld ln -s /usr/local/mysql/bin/mysql /usr/bin chmod +x /etc/init.d/mysqld # 加入开机起动 #chkconfig --add mysqld #5、启动mysql service mysqld start # # ##登录修改密码 mysql -uroot -p 上面初始化时的密码 # #grep 'temporary password' /usr/local/mysql/log/mysqld.log # #alter user 'root'@'localhost' identified by 'root'; # #GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mysql.7335553' WITH GRANT OPTION; #授权新用户 #flush privileges; #刷新权限
最后就是注释的几个 启动mysql 登录mysql 授权就可以了