在 官方网址下载
安装步骤如下
root@z01:~/files
# groupadd mysql
root@z01:~/files
# useradd -r -g mysql -s /bin/false mysql
root@z01:~/files
# cd /usr/local
root@z01:/usr/local
# tar -zxf ~/files/mysql-5.7.26-el7-x86_64.tar.gz
root@z01:/usr/local
# ln -s mysql-5.7.26-el7-x86_64 mysql
root@z01:/usr/local
# chown -R mysql:mysql mysql/
root@z01:/usr/local
# cd mysql
root@z01:/usr/local/mysql
# mkdir data
root@z01:/usr/local/mysql
# chown mysql:mysql data
root@z01:/usr/local/mysql
# chmod 750 data
root@z01:/usr/local/mysql
# vim /etc/my.cnf
内容如下
[mysqld]
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/mysql.sock
#log-error=/var/log/mariadb/mariadb.log
#pid-file=/var/run/mariadb/mariadb.pid
[client]
socket=/usr/local/mysql/mysql.sock
root@z01:/usr/local/mysql
# bin/mysqld --initialize --user=mysql
记得保存初始密码
root@z01:/usr/local/mysql
# bin/mysql_ssl_rsa_setup
启动
root@z01:/usr/local/mysql
# bin/mysqld_safe &
测试
root@z01:/usr/local/mysql
# bin/mysql -u root -p
重置密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
远程访问
mysql> grant all privileges on *.* to 'root'@'%' identified by 'root';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)