Centos7安装MySQL5.7

mtain 2022年06月10日 853次浏览

1. 安装

yum localinstall -y mysql-*.rpm

2. 初始化mysql

更改mysql数据库所属于用户及其所属于组

mysqld --initialize
chown mysql:mysql /var/lib/mysql -R

3. 启动mysql数据库

[root@test mysql]# systemctl start mysqld.service
[root@test ~]# grep 'password' /var/log/mysqld.log 
2023-04-14T06:57:30.646293Z 1 [Note] A temporary password is generated for root@localhost: kdfYnW87&:lm

4. 修改数据库密码

[root@hadoop log]# mysql -u root -p

mysql中执行
set password=password('EuuWwnZK3frG');
flush privileges;
grant all privileges on *.* to root@'%' identified by 'EuuWwnZK3frG' with grant option;
flush privileges;

5. 设置字符编码和表名不区分大小写

vi /etc/my.cnf
增加

[mysqld]
character-set-server=utf8
lower_case_table_names=1

systemctl restart mysqld.service
systemctl enable mysqld.service