使用mysql-8.0.27-1.el7.x86_64.rpm-bundle.tar安装mysql
1、解压
tar -xvf mysql-8.0.27-1.el7.x86_64.rpm-bundle.tar
2、依次安装
rpm -ivh mysql-community-common-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.27-1.el7.x86_64.rpm
3、查看mysql的状态
systemctl status mysqld
4、停止mysql
service mysqld stop
5、设置数据库不区分表名大小写
vim /etc/my.cnf
[mysqld]
lower_case_table_names=1
6、初始化数据库
mysqld --initialize --console
7、目录授权
chown -R mysql:mysql /var/lib/mysql/
8、启动mysql服务
systemctl start mysqld
systemctl status mysqld
9、查看root账号的临时密码 Kz-8/=f#5cdm
cat /var/log/mysqld.log
日志中临时密码示例:A temporary password is generated for root@localhost: p2gF*
10、使用临时密码登录
mysql -u root -p
11、授权远程访问
show databases;
use mysql;
select host, user, authentication_string, plugin from user;
update user set host = "%" where user='root';
select host, user, authentication_string, plugin from user;
flush privileges;
12、修改密码及加密方式
alter USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
flush privileges;
0
posted on 2023-06-27 15:52  twm7512  阅读(43)  评论(0编辑  收藏  举报