Centos 安装mysql8(YUM方式)
1、执行安装命令
[root@localhost ~]# wget https://dev.mysql.com/get/mysql80-community-release-el8-4.noarch.rpm
[root@localhost ~]# yum module disable mysql
[root@localhost ~]# yum install mysql-community-server
2、修改配置文件
[root@localhost ~]# vi /etc/my.cnf
[root@localhost ~]# 新增配置
wait_timeout=32000
slow_query_log = ON
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 2
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
init_connect='SET NAMES utf8mb4'
max_connections=1000
3、设置开机启动
[root@localhost ~]# systemctl enable mysqld
[root@localhost ~]# systemctl daemon-reload
4、启动mysql
[root@localhost ~]# systemctl start mysqld
5、查找初始密码
grep 'temporary password' /var/log/mysqld.log
如果无效 修改 /etc/my.cnf 添加 skip-grant-tables 后重新启动
然后mysql -u root -p 进入mysql 修改密码为空
update user set authentication_string='' where user='root';
将skip-grant-tables删除后,重新启动
ALTER USER USER() IDENTIFIED BY 'Admin2023!';
6、创建数据库
mysql> create database 'easydb';
mysql> CREATE USER 'test'@'%' IDENTIFIED with mysql_native_password BY 'Test_0316';
mysql> GRANT ALL ON easydb.* TO 'test'@'%' WITH GRANT OPTION;