Centos 安装mysql

Centos 安装mysql

1.安装wget(类似迅雷下载工具)

yum install wget

2.下载MySQL官方的 Yum Repository(安装仓库)

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

3.yum安装MySQL官方的 Yum Repository

yum -y install mysql57-community-release-el7-10.noarch.rpm

4.安装MySQL服务器

yum -y install mysql-community-server

查看mysql安装目录命令

whereis mysql

查看mysql执行文件命令 which mysql

which mysql

5.启动mysql

systemctl start mysqld.service

6.找出初始密码

grep "password" /var/log/mysqld.log

7.进入数据库

mysql -uroot -p

出现错误(Access denied for user 'root'@'localhost' (using password: YES)解决方案
1.修改/etc/my.cnf新增skip-grant-tables配置参数
2.重启服务service mysqld restart
3.进入mysql mysql -uroot -p
4.修改初始密码

update mysql.user set authentication_string=password('123456') where user='root';

5.退出mysql 改回my.cnf重启服务 service mysqld restart

8.用初始密码登录后修改安全密码

//注意需要分号;
ALTER USER 'root'@'localhost' IDENTIFIED BY '安全新密码';
//刷新权限配置
flush privileges;
exit;

9.开启远程访问

//全部可以访问ip替换成%
grant all privileges on *.* to 'root'@'192.168.0.1' identified by '替换密码' with grant option;
//刷新权限配置
flush privileges;
exit;

10.开放端口

//mysql
firewall-cmd --zone=public --add-port=3306/tcp --permanent
//tomcat
firewall-cmd --zone=public --add-port=8080/tcp --permanent
//重启防火墙
firewall-cmd --reload

11.修改mysql语言

1.进入mysql 查看状态 status
2.修改etc目录下的my.cnf
[client]节点下增加 default-character-set=utf8
[mysqld]节点下增加 character-set-server=utf8 collation-server=utf8_general_ci
在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值