1.安装lib包
yum install libaio
yum -y install numactl
2. 下载mysql mysql-8.0.17-el7-x86_64.tar.gz
3.解压 tar -xzvf mysql-8.0.17-el7-x86_64.tar.gz
4.新建 my.conf
[mysqld]
port=3306
basedir=/home/yanlei/mysql/mysql-8.0.17-el7-x86_64
datadir=/home/yanlei/mysql/data
log-error=/home/yanlei/mysql/log/error.log
pid-file=/home/yanlei/mysql/mysqld.pid
character_set_server=utf8
default-storage-engine=INNODB
default_authentication_plugin=mysql_native_password
[mysql]
default-character-set=utf8
[client]
port=3306
default-character-set=utf8
5.初始化数据库
bin/mysqld --initialize --defaults-file=/home/yanlei/mysql/my.conf
[System] [MY-013169] [Server] /home/yanlei/mysql/mysql-8.0.17-el7-x86_64/bin/mysqld (mysqld 8.0.17) initializing of server in progress as process 7126
[Note] [MY-010454] [Server] A temporary password is generated for root@localhost: (c2l_Amfo?O?
[System] [MY-013170] [Server] /home/yanlei/mysql/mysql-8.0.17-el7-x86_64/bin/mysqld (mysqld 8.0.17) initializing of server has completed
6.启动mysql
bin/mysqld --defaults-file=/home/yanlei/mysql/my.conf&
7.mysql 客户端登录(密码使用初始化数据库控制台输出的密码)
mysql -u root -p
8.修改root 密码
ALTER user 'root'@'localhost' IDENTIFIED BY '密码值';
9.创建数据库
create database testdb character set utf8 collate utf8_general_ci;
10.创建新用户并赋权
CREATE USER 'yanlei'@'%' IDENTIFIED BY '密码';
GRANT ALL ON *.* TO 'yanlei'@'%';
11. 停止服务脚 本
mysqladmin --socket=/home/mysql/mysql/mysql.sock -u root -p --password=123456 shutdown