官方安装文档https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html
1、创建安装用户
[root@localhost ~]# useradd -s /bin/false -d /home/soft/mysql mysql
[root@localhost ~]# id mysql
2、解压安装 mysql 8 官方下载地址
[root@localhost backup20180428]# tar -zxvf mysql-8.0.11-el7-x86_64.tar.gz -C /home/soft/mysql/
3、从命名,创建data文件夹
[root@localhost mysql]# cd mysql-8.0.11-el7-x86_64/
[root@localhost mysql-8.0.11-el7-x86_64]# mv * ../
[root@localhost mysql-8.0.11-el7-x86_64]# cd ..
[root@localhost mysql]# mkdir data
4、赋予mysql用于组权限
[root@localhost mysql]# chown -R mysql.mysql ../mysql
5、mysql安装
[root@localhost mysql]# cd bin
[root@localhost bin]# ./mysqld --user=mysql --basedir=/home/soft/mysql --datadir=/home/soft/mysql/data --initialize
[root@localhost bin]# cp ../support-files/mysql.server /etc/init.d/mysqld
6、配置过程
[mysqld]
port = 3306
basedir = /home/soft/mysql
datadir=/home/soft/mysql/data
socket=/tmp/mysql.sock
pid-file=/home/soft/mysql/data/mysql.pid
log-error=/home/soft/mysql/data/error.log
character_set_server=utf8
user=mysql
max_connections=1500
symbolic-links=0
!includedir /etc/my.cnf.d
7、启动登录,密码是五步骤中的红色 noByUT7umW,o
[root@localhost ~]# service mysqld start
[root@localhost ~]# cd /home/soft/mysql/
[root@localhost mysql]# ./bin/mysql -u root -p
8、登录成功后修改密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'YlanHdsNewPass4!';
或者
mysql> set password for 'root'@'localhost'=password('YlanHdsNewPass4')
9、其他:
启动MySQL服务
[root@localhost ~]# service mysqld start
登录
[root@localhost mysql]# ./bin/mysql -uroot -p
添加远程登录用户,在登录状态下
mysql> GRANT ALL PRIVILEGES ON *.* TO 'ylanhds'@'%' IDENTIFIED BY 'YlanHds2018!' WITH GRANT OPTION;