下载mysql版本

#wget  https://dev.mysql.com/get/mysql80-community-release-el7-6.noarch.rpm

安装mysql

#rpm -ivh  mysql80-community-release-el7-6.noarch.rpm
yum install mysql-server --nogpgcheck -y


权限设置

#chown -R mysql:mysql /var/lib/mysql/


初始化 MySQL

#mysqld --initialize


启动 MySQL

#systemctl start mysqld

查看 MySQL 运行状态

#systemctl status mysqld



查看MySQL版本

#mysql --version

Linux部署mysql8.0_mysql 部署


查看MySQL默认密码

#vim /var/log/mysqld.log
2022-07-11T12:34:53.875447Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-07-11T12:34:54.799252Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: oDiM;dd/Q1#h

查看“A temporary password” 就能看到密码


命令查看默认密码

#grep "password is generated" /var/log/mysqld.log | awk '{print $NF}'

Linux部署mysql8.0_mysql 部署_02


登陆MySQL

#mysql -u root -p

输入默认密码:“oDiM;dd/Q1#h”,请根据实际密码修改

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'NetPassword';

Linux部署mysql8.0_mysql 部署_03