#1.下载和安装mysql
wget -i -c https://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum module disable mysql
yum -y install mysql-community-server
#2.MySQL数据库设置
#启动mysql
systemctl start mysqld.service
#查看mysql运行状态,输入q退出命令行状态
systemctl status mysqld.service
#查看mysql初始密码
grep "password" /var/log/mysqld.log
#进入数据库并输入初始密码
mysql -uroot -p
#修改初始密码
alter user 'root'@'localhost' identified by 'l1icznxqwhD&53J^';
#3.开启mysql的远程访问
grant all privileges on *.* to 'root'@'%' identified by 'l1icznxqwhD&53J^' with grant option;
flush privileges;
exit;
#4.防火墙添加端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
#5.格式改为utf8
vim /etc/my.cnf
#首行添加
[client]
default-character-set=utf8
#socket行后添加,Esc,输入:wq!,回车强制保存
character-set-server=utf8
collation-server=utf8_general_ci
#重启mysql
service mysqld restart
记录 MySQL安装——CentOS8安装Mysql
最新推荐文章于 2024-08-15 18:29:32 发布