创建basedir,datadir,用户,组
shell>groupadd mysqlshell>useradd -g mysql mysqlshell>mkdir /appshell>mkdir /datashell>chown -R mysql.mysql /appshell>chown -R mysql.mysql /data
解压,并改名
shell> cd /app
shell> tar -zxvf mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz
mysql-5.7.30-linux-glibc2.12-x86_64/bin/myisam_ftdump
mysql-5.7.30-linux-glibc2.12-x86_64/bin/myisamchk
mysql-5.7.30-linux-glibc2.12-x86_64/bin/myisamlog
mysql-5.7.30-linux-glibc2.12-x86_64/bin/myisampack
mysql-5.7.30-linux-glibc2.12-x86_64/bin/mysql
mysql-5.7.30-linux-glibc2.12-x86_64/bin/mysql_client_test_embedded
mysql-5.7.30-linux-glibc2.12-x86_64/bin/mysql_config_editor
mysql-5.7.30-linux-glibc2.12-x86_64/bin/mysql_embedded
mysql-5.7.30-linux-glibc2.12-x86_64/bin/mysql_install_db
mysql-5.7.30-linux-glibc2.12-x86_64/bin/mysql_plugin
mysql-5.7.30-linux-glibc2.12-x86_64/bin/mysql_secure_installation
mysql-5.7.30-linux-glibc2.12-x86_64/bin/mysql_ssl_rsa_setup
mysql-5.7.30-linux-glibc2.12-x86_64/bin/mysql_tzinfo_to_sql
mysql-5.7.30-linux-glibc2.12-x86_64/bin/mysql_upgrade
.....
shell> mv mysql-5.7.30-linux-glibc2.12-x86_64/ mysql/
修改环境变量
shell> vi /etc/profile
export PATH=/app/mysql/bin:$PATH
shell> source /etc/profile
复制启动文件
shell> cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld
shell> chmod 755 /etc/init.d/mysqld
shell> cp /app/mysql/bin/my_print_defaults /usr/bin/
编辑配置文件
shell> vi /etc/my.cnf
[mysqld]
basedir=/app/mysql
datadir=/data
socket=/tmp/mysql.sock
user=mysql
port=3306
server_id=1
初始化
shell> /app/mysql/bin/mysqld --initialize-insecure --user=mysql --datadir=/data --basedir=/app/mysql/
2021-05-27T23:37:06.606282Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-05-27T23:37:06.776540Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-05-27T23:37:06.814975Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-05-27T23:37:06.910201Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 72c49f49-bf44-11eb-9977-000c29c687c0.
2021-05-27T23:37:06.925699Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-05-27T23:37:07.333805Z 0 [Warning] CA certificate ca.pem is self signed.
2021-05-27T23:37:07.606492Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
启动数据库并修改密码
shell>/etc/init.d/mysqld start
mysql>set password for root@'localhost'=password('Mysql5.7');
mysql>flush privileges;
添加mysqld到开机自启
shell> chkconfig --add mysqld
