Centos7.2 安装Mysql 5.7
2019-10-09 本文已影响0人
pokerface_max
- 下载安装源
wget https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
- 安装rpm
yum localinstall mysql57-community-release-el7-8.noarch.rpm
- 查看rpm源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
4.安装
yum install mysql-community-server
- 启动
systemctl start mysqld
systemctl status mysqld
systemctl enable mysqld
systemctl daemon-reload
- 查看修改密码
默认密码在/var/log/mysqld.log文件中
取得默认密码,最好复制
grep 'temporary password' /var/log/mysqld.log
- 修改密码
mysql -u root -p
输入刚复制的密码
set password for 'root'@'localhost'=password('新密码');
- 查看和修改数据库的默认字符集
show variables like '%character%';
set character_set_database = utf8mb4;
9.创建数据库
create database $DATABASENAME;
9.创建用户
create user "username"@"host" identified by "password";
- 授权
grant all privileges on $DBNAME.* to $USER@'%' identified by '$PASSWORD';
flush privileges;