CentOS安装MySQL及其使用(总结整理)
安装MySQL
1先检查系统是否装有mysql
rpm -qa | grep mysql
2 下载mysql的repo源
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
如果报错: -bash: wget: 未找到命令,安装插件yum -y install wget
。
3 安装 mysql-community-release-el7-5.noarch.rpm包
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
4 安装MySQL
sudo yum install mysql-server
5 重启MySQL服务
service mysqld start
6 查看MySQL是否启动成功
service mysqld status
netstat -nltp | grep mysqld
修改root密码(忘记root密码)
1 停止mysql服务
service mysqld stop
2 修改配置文件/etc/my.cnf
打开/etc/my.cnf,
在[mysqld]下添加skip-grant-tables,意思是忽略密码,保存并退出。
3 启动Mysql
service mysqld start
4 修改密码
输入命令mysql // 步骤1
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3 to server version: 3.23.56
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> USE mysql; // 步骤2
Database changed
mysql> UPDATE user SET Password = password ('new-password') WHERE User = 'root'; // 步骤3
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges; // 步骤4
Query OK, 0 rows affected (0.01 sec)
mysql> quit // 步骤5
5 改回配置,重启服务
打开/etc/my.cnf,
在[mysqld]下删除skip-grant-tables,保存并退出。
重启mysql,
service mysqld restart。
外网无法连接到MySQL的处理方法
使用mysql -u root -p登录到mysql中。
登录后执行如下命令:
use mysql;
select host from user where user=‘root’;
修改帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入MySQL后,更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从"localhost"改称"%":
update user set host = ‘%’ where user =‘root’;
刷新配置即可。
flush privileges;
参考资料
CentOS7.5 安装MySql的教程
CentOS下mysql忘记root密码解决办法
is not allowed to connect to this mysql server
CentOS安装MySQL及其使用(总结整理)相关推荐
- centos安装MySQL怎么换端口_centos安装mysql后3306端口不通
centos安装mysql后3306端口不通,端口,发现,教程,重启,解决方法 centos安装mysql后3306端口不通 易采站长站,站长之家为您整理了centos安装mysql后3306端口不通 ...
- centOS安装Mysql指南
centOS安装Mysql指南 说明:使用操作系统centOS6.4 32位系统:mysql:mysql-5.7.10-linux-glibc2.5-i686.tar.gz; 一.准备 下载mysql ...
- centos 安装MySQL报错You could try using --skip-broken to work around the problem You could try running:
centos 安装MySQL报错You could try using --skip-broken to work around the problem You could try running: ...
- Linux/CentOS安装MySQL(RPM安装、编译安装)
2019独角兽企业重金招聘Python工程师标准>>> Linux/CentOS安装MySQL(RPM安装.编译安装) 目前最常用的MySQL安装方法也就是采用Yum安装RPM包,或 ...
- MySQL之CentOS安装MySQL
文章目录 CentOS安装MySQL 安装MySQLServer Liunx发行版的本地软件库的MySQL版本安装 通过yum安装命令安装 systemctl命令启动MySQLServer 查看安装的 ...
- centos 安装mysql 5.7
centos安装mysql 1.检查系统中是否已安装 MySQL. 如果已安装,请参考此文章卸载). rpm -qa | grep mysql 在新版本的CentOS7中,默认的数据库已更新为了Mar ...
- Centos安装MySQL详细步骤(亲妈级教程)
Centos安装MySQL详细步骤(亲妈级教程) {ubuntu安装mysql,其他linux安装MySQL同理} 0.下载 官网下载:MySQL 百度云下载: 链接:https://pan.baid ...
- Centos安装mysql rpm包
Centos安装mysql rpm包 安装mysql步骤: 清理环境 centos有可能会自带一个mariadb 查看是否已安装 rpm -qa |grep -i mysql #(centos7默认系 ...
- Centos安装MySQL(RPM安装方式)
Centos安装MySQL(RPM安装方式) 1.centos中以rpm安装包的方式进行安装测试 2.在MySQL官网下载安装包官网下载 Product Version:5.7.33 Operatin ...
- centos 6.7 mysql 5.6_CentOS 6.7 安装 MySQL 5.6 思路整理
源代码及兼容包 源代码包下载:官网 > Downloads > MySQL Community Edition (GPL) > MySQL Community Server (GPL ...
最新文章
- Python——阶段总结(一)
- python for循环习题
- 服务器网站数据用什么方式加以保留?
- [转] iOS中@class #import #include 简介
- Vue+blockly 制作与自定义美化
- GitHub 基本常用知识解答2
- jinja2语法中{%raw%}和{{}}的等效替换
- html转换jquery,将html字符串转化为jquery对象
- 李宏毅机器学习-- RNN
- java中的BigDecimal类型
- 专访许鹏:谈C程序员修养及大型项目源码阅读与学习
- 边缘计算助力产业数字化转型
- 现代黄河三角洲的冲淤分区及地层特征(二)
- Android使用GoogleMap实现定位及定位回正
- df命令和du命令-个人
- 《炬丰科技-半导体工艺》化学清洗过程中重金属污染的监测方法
- react-native trampoline实现 1
- 3ds Max人物女性角色模型建模教程
- 门禁布线系统常见错误详解
- python 中利用字典给所有的符号编号