在 CentOS7 中我们在安装 MySQL

1、下载rpm

wget -i -c https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm​

2、使用yum进行安装

yum -y install mysql80-community-release-el7-1.noarch.rpm

3、安装mysql

yum -y install mysql-community-server​

4、启动mysql

systemctl start mysqld.service

5、查看运行状态

systemctl status mysqld.service

6、查看root用户名密码

grep "passsword" /var/log/mysqld.log

7、登录mysql数据库

mysql -uroot -p 输入密码进入数据库

8、修改root密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

9、卸载Yum Repository

yum -y remove mysql80-community-release-el7-1.noarch

10、设置开机启动

shell> systemctl enable mysqld
shell> systemctl daemon-reload

11、创建用户,添加远程登录

创建用户
mysql>create user 用户名@'%' identified  by '密码';
进行赋值
mysql>grant all privileges on *.* to 用户名@'%' with grant option;
最后刷新
mysql>flush privileges;

12、设置utf-8编码

修改/etc/my.cnf配置文件

[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'

13、重启mysql

systemctl restart mysqld

  

原文地址:https://www.cnblogs.com/hyh123/p/14272320.html