依赖包安装
# dnf yum -y install wget cmake gcc gcc-c++ ncurses ncurses-devel libaio-devel openssl openssl-devel perl
创建mysql用户
# groupadd mysql
# useradd mysql -d /var/lib/mysql/ -g mysql
# tail -1 /etc/passwd
mysql:x:1000:1000::/var/lib/mysql/:/bin/bash
获取mysql-8.0.31安装包
# wget -c https://dev.mysql.com/get/mysql-8.0.31-1.el8.x86_64.rpm-bundle.tar
# tar -xvf mysql-8.0.31-1.el8.x86_64.rpm-bundle.tar
安装mysql
# rpm -ivh mysql-community-common-8.0.31-1.el8.x86_64.rpm
# rpm -ivh mysql-community-client-plugins-8.0.31-1.el8.x86_64.rpm
# rpm -ivh mysql-community-libs-8.0.31-1.el8.x86_64.rpm
# rpm -ivh mysql-community-client-8.0.31-1.el8.x86_64.rpm
# rpm -ivh mysql-community-icu-data-files-8.0.31-1.el8.x86_64.rpm
# rpm -ivh mysql-community-server-8.0.31-1.el8.x86_64.rpm
初始化mysql数据库
# mysqld --initialize --console
查看数据库初始化密码
# cat /var/log/mysqld.log | grep localhost
2023-01-13T19:01:34.497431Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: yl)TpkEQj9B6
启动mysql服务
# chmod 777 /var/lib/mysql/auto.cnf
# chown -R mysql:mysql /var/lib/mysql/
# systemctl start mysqld
# systemctl status mysqld
# systemctl enable mysqld
确认数据库版本
# mysqladmin --version
mysqladmin Ver 8.0.31 for Linux on x86_64 (MySQL Community Server - GPL)
确认mysql版本
# mysqladmin --version
mysqladmin Ver 8.0.31 for Linux on x86_64 (MySQL Community Server - GPL)
修改mysql数据库root密码
# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.31
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.03 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
开启开启mysql的远程访问
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql>
网友评论