1、下载MySQL 安装包:
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
yum -y localinstall mysql57-community-release-el7-11.noarch.rpm
2、在线安装MySQL
yum -y install mysql-community-server
3、启动mysql 服务
systemctl start mysqld
4、设置开机启动
systemctl enable mysqld
systemctl daemon-reload
5、修改root登录密码
- mysql安装完成之后,会在/var/log/mysqld.log文件中给root生成了一个临时的默认密码。
vim /var/log/mysqld.log
2020-07-21T06:45:28.566414Z 1 [Note] A temporary password is generated for root@localhost: TxUa>Lh>D7B!
- 记住初始密码,修改root 密码:
mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码'
- #设置远程登录
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '新密码' WITH GRANT OPTION;
6、退出
exit
7、配置mysql默认编码为utf-8
vim /etc/my.cnf
添加如下代码
character_set_server=utf8
init_connect='SET NAMES utf8'
systemctl restart mysqld
重启mysql- 进入mysql使用
show variables like '%character%';
查看编码格式!