【centos7 + MySQL5.7 安装】centos7 安装MySQL5.7

第一步、下载MySQL 安装包:
[root@localhost local]# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
安装mysql 安装源:
[root@localhost local]# yum -y localinstall mysql57-community-release-el7-11.noarch.rpm
第二步,在线安装MySQL
[root@localhost local]# yum -y install mysql-community-server
等待时间比较久。
第三步、启动mysql 服务
[root@localhost local]# systemctl start mysqld
第四步,设置开机启动
[root@localhost local]# systemctl enable mysqld
[root@localhost local]# systemctl daemon-reload
第五步,修改root登录密码
mysql安装完成之后,会在/var/log/mysqld.log文件中给root生成了一个临时的默认密码。
[root@localhost local]# vim /var/log/mysqld.log
记住初始密码:
修改root 密码
[root@localhost local]# mysql -u root -p
mysql> ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘daasan7ujm^YHN’;
Query OK, 0 rows affected (0.00 sec)
设置远程登录:
mysql> GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘daasan7ujm^YHN’ WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)
第六步,退出
mysql> exit
第七步,关闭防火墙
第八步,配置mysql默认编码为utf-8
[root@localhost sysconfig]# vim /etc/my.cnf
添加如下代码
character_set_server=utf8
init_connect=‘SET NAMES utf8’
:wq 保存退出
第九步,重启MySQL
[root@localhost data]# systemctl restart mysqld
第十步, root 用户登录查看编码
[root@localhost sysconfig]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.29 MySQL Community Server (GPL)

Copyright © 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> show variables like ‘%character%’;
±-------------------------±---------------------------+
| Variable_name | Value |
±-------------------------±---------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
±-------------------------±---------------------------+
8 rows in set (0.00 sec)

最后本地连接测试:

adrai.github.io/flowchart.js/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值