1、准备安装包 mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz,解压
[root@T-DMP-01 ~]# tar zxf mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz -C /data/ [root@T-DMP-01 data]# ln -s /data/mysql-5.7.15-linux-glibc2.5-x86_64/ /data/mysql [root@T-DMP-01 data]# cd /data/mysql [root@T-DMP-01 ~]#mkdir data //新建文件夹data [root@T-DMP-01 ~]#mkdir mysql-files [root@T-DMP-01 ~]#groupadd mysql //新建mysql组 [root@T-DMP-01 ~]#useradd -g mysql mysql [root@T-DMP-01 ~]#chown -R mysql:mysql /data/mysql
2、修改配置文件/etc/my.cnf
[root@T-DMP-01 mysql]# cat /etc/my.cnf [mysqld] port=3306 basedir=/data/mysql datadir=/data/mysql/data socket=/data/mysql/mysql.sock log_error=/data/mysql/mysql_error.log [client] port=3306 socket=/data/mysql/mysql.sock
3、初始化数据库
[root@T-DMP-01 bin]# ./mysqld --initialize --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data
查看密码:
[root@T-DMP-01 mysql]# bin/mysql_ssl_rsa_setup --datadir=/data/mysql/data //设置ssl可以不用执行 Generating a 2048 bit RSA private key ..........................................................................................................................................................................................................+++ ........................................+++ writing new private key to 'ca-key.pem' ----- Generating a 2048 bit RSA private key ....+++ ................+++ writing new private key to 'server-key.pem' ----- Generating a 2048 bit RSA private key .....+++ ..................................................+++ writing new private key to 'client-key.pem' -----
4、启动MySQL
[root@T-DMP-01 support-files]# su mysql
[mysql@T-DMP-01 support-files]# ./mysql.server start Starting MySQL. SUCCESS! [mysql@T-DMP-01 support-files]# pwd /data/mysql/support-files
5、修改密码
[mysql@localhost bin]$ ./mysqladmin -u root -p password 'JchangI2021';
6、给root赋予远程登陆权限
mysql> grant all on *.* to root@'%' identified by 'WWW.1.com' with grant option;
参考:https://www.cnblogs.com/haima/p/12276063.html
https://www.jb51.net/article/174244.htm