Centos 安装mysql
1、下载安装mysql
下载mysql源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
安装mysql
yum install mysql-community-server
2、启动MySQL服务
systemctl start mysqld
systemctl status mysqld
3、设置密码
查看初始密码
grep 'temporary password' /var/log/mysqld.log
登录mysql
mysql -uroot -p
修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NEWpass123,';
4、添加远程登录账户
GRANT ALL PRIVILEGES ON *.* TO 'sa1'@'%' IDENTIFIED BY 'SAsa123,' WITH GRANT OPTION;
5、配置默认编码为utf8
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置,
[mysqld] character_set_server=utf8 init_connect='SET NAMES utf8'
重启mysql服务
systemctl restart mysqld
6、使用navicat远程链接数据
参考文章:centos安装MySQL5.7