mySql 在Linux上安装
16lz
2021-04-16
1、下载mysql安装包
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm复制代码
2、安装mysql源
yum -y localinstall mysql80-community-release-el7-3.noarch.rpm复制代码
3、安装mysql server
yum -y install mysql-community-server复制代码
4、启动mysql
systemctl start mysqld复制代码
5、设置开机启动
systemctl enable mysqldsystemctl daemon-reload复制代码
6、查看默认密码
cat /var/log/mysqld.log | grep password复制代码
7、修改数据库密码
先 mysql -uroot -p登录
输入命令修改
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'hsywhy1212.';exit 退出复制代码
8、设置远程访问权限
先登录数据库mysql -uroot -p登录
加密创建远程root用户 执行
create user 'root'@'%' identified with mysql_native_password by '你的密码';复制代码
赋予权限 执行
grant all privileges on *.* to 'root'@'%' with grant option;复制代码
刷新权限
flush privileges;复制代码
退出 exit
9、打开防火墙3306端口
systemctl start firewalld复制代码
开放3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent复制代码
防火墙重新加载配置 执行
firewall-cmd --reload复制代码
别忘了在服务器安全组也配置3306端口
10、配置数据库utf-8
/etc/my.cnf文件 添加以下编码配置
character_set_server=utf8init_connect='SET NAMES utf8'复制代码
cd /etc
vim my.cnf
i 是编辑 esc : wq 退出
11、重启mysql
systemctl restart mysqld
作者:皮皮猪_
链接:https://juejin.cn/post/6916809760046055432
更多相关文章
- 架构秘笈:移花接木。使用mysql模拟redis
- 运营商劫持狠起来,连json都改
- String.replaceAll方法,正则妙用
- Spring Cloud Gateway2.0实践报告
- 实现文件上下文管理(__enter__和__exit__)
- 第14部分- Linux ARM汇编数组/结构体/索引
- 第4部分- Linux ARM汇编首个程序
- 第12部分- Linux ARM汇编 控制指令
- 流程控制之if判断