yum install mysql-server mysql -y
# 初始化 MySQL:
mysqld --initialize
chown -R mysql:mysql /var/lib/mysql/
systemctl start mysqld
systemctl status mysqld
netstat -nltp
# 查找初始密码
grep 'temporary password' /var/log/mysql/mysqld.log
vim /etc/my.cnf
在[mysqld]后添加skip-grant-tables(登录时跳过权限检查)
systemctl restart mysqld
mysql -u root -p
# 刷新权限
flush privileges;
# 修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'qwer1234!@#$';
去掉skip-grant-tables参数
systemctl restart mysqld
mysql -u root -p
use mysql;
select host, user, authentication_string, plugin from user;
update user set host='%' where user='root';
# 执行两次
GRANT ALL ON *.* TO 'root'@'%';
flush privileges;
mysql -u root -p
# 创建一个数据库
create database community_data;
# 查看当前用户下所有数据库
show databases;
# 查看所有的用户
select host,user from mysql.user;
# 查看当前用户
select current_user();
# 查看当前用户权限
show grants;
linux安装mysql 8
于 2024-08-06 19:11:31 首次发布