腾讯云主机安装登录mysql失败--解决方案[重置root密码并实现远程连接]
登录MySQL时报错:Access denied for user 'root'@'localhost' (using password: YES)
解决步骤:
1、使用ssh工具连接主机,使用mysqld_safe命令进入安全模式:
Last login: Thu Jun 22 09:56:57 2017 from 182.50.118.228
[root@VM_219_131_centos ~]# service msyqld status
msyqld: unrecognized service
[root@VM_219_131_centos ~]# service mysqld stop
Stopping mysqld: [ OK ]
[root@VM_219_131_centos ~]# service msyqld status
msyqld: unrecognized service
[root@VM_219_131_centos ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[] 4436
[root@VM_219_131_centos ~]# 170622 09:58:15 mysqld_safe Logging to '/var/log/mysqld.log'.
170622 09:58:15 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
170622 10:02:45 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
2、再打开一个窗口,连接MySQL,就可以为root用户设置密码了:
Last login: Thu Jun 22 09:57:25 2017 from 182.50.118.228
[root@VM_219_131_centos ~]# mysql -uroot mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, 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> UPDATE user SET Password=PASSWORD('你的密码') where USER='root' and host='root' or host='localhost';
Query OK, 2 rows affected (0.03 sec)
Rows matched: 2 Changed: 2 Warnings: 0 mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec) mysql> quit
Bye
[root@VM_219_131_centos ~]#
3、打开远程连接权限:
Last login: Thu Jun 22 09:58:24 2017 from 182.50.118.228
[root@VM_219_131_centos ~]# service mysqld status
mysqld (pid 4532) is running...
[root@VM_219_131_centos ~]# service mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
[root@VM_219_131_centos ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, 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 databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec) mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '你的密码' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec) mysql>
4、使用Navicat工具远程连接,点击左下角的"连接测试",连接成功:

腾讯云主机安装登录mysql失败--解决方案[重置root密码并实现远程连接]的更多相关文章
- Ubuntu腾讯云主机安装分布式memcache服务器,C#中连接云主机进行存储的示例
Ubuntu腾讯云主机安装分布式memcache服务器,C#中连接云主机进行存储的示例(github代码:https://github.com/qq719862911/MemcacheTestDemo ...
- 【转】CentOS6下安装mysql后,重置root密码方法
本文转自:CentOS6下安装mysql后,重置root密码方法 centos下安装mysql,居然不知道root用户密码,本想重装,不过还是先度娘了一些,发现这篇文章,刚好解决我的燃眉之急,太赞了. ...
- 腾讯云ubuntu安装使用MySQL
安装步骤 ubuntu@VM---ubuntu:~$ sudo apt-get install mysql-server (密码: root/root) ubuntu@VM---ubuntu:~$ s ...
- Navicat连接远程主机(腾讯云服务器)的mysql失败,解决
赋予所有用户远程连接的权限,重启mysql即可连接成功: grant all privileges on . to 'root'@'%' identified by 'admin'; systemct ...
- MySql 5.7 重置root密码
一.以安全模式登录 # Stop MySQL sudo service mysql stop # Make MySQL service directory. sudo mkdir -p /var/ru ...
- 腾讯云主机 MySQL 远程访问配置方法
使用腾讯云主机安装 MySQL 之后,需要通过以下步骤进行配置以实现远程访问,主要分为两大部分 一.服务器端口配置 1.如果你的云主机配置了安全组,如果没有配置安全组就可以直接跳过“步骤1”的操作,否 ...
- 访问腾讯云主机mysql的设置问题
---恢复内容开始--- 1.需要打开腾讯云主机的防火墙端口3306,具体实现可以在腾讯云控制台安全组中设置开放全部端口(安全组对应入站.出战规则): 2.将云主机mysql中mysql数据库user ...
- 腾讯云 ubuntuservermysql安装和外网訪问
1 腾讯云 购买ubuntu 默认账户是ubuntu(因为winscp 使用ubuntu没有权限写文件) 因为腾讯云主机ubuntu系统默认username为ubuntu,不喜欢每次做什么都要sudo ...
- 腾讯云-ASP.NET Core+Mysql+Jexus+CDN上云实践
腾讯云-ASP.NET Core+Mysql+Jexus+CDN上云实践.md 开通腾讯云服务器和Mysql 知识点: ASP.NET Core和 Entity Framework Core的使用 L ...
随机推荐
- Linux下找不到动态链接库;
目前,在做的一个程序,编译完后,运行发现报错说找不到自己编译生成的动态库文件,很尴尬;;;果断查资料解决,捎带复制一篇写的比较完善的文章, 地址:http://www.cnblogs.com/wies ...
- vim缩进参考线
编辑缩进嵌套的文件时想找到对应的层级比较困难,写了一个函数,使用cc选项设定一条辅助线,标识到指定的缩进层级.代码如下: ? ReferenceLine 1 2 3 4 5 6 7 8 9 10 11 ...
- SoapUI利用Groovy对response与断言的处理
1.对response的处理:(其中Test Request是request的名称) def groovyUtils = new com.eviware.soapui.support.GroovyUt ...
- 消息队列状态:struct msqid_ds
Linux的消息队列(queue)实质上是一个链表, 它有消息队列标识符(queue ID). msgget创建一个新队列或打开一个存在的队列; msgsnd向队列末端添加一条新消息; msgrcv从 ...
- Ubuntu菜鸟入门(十六)—— 安装视频播放器vlc
sudo add-apt-repository ppa:videolan/master-daily sudo apt-get update sudo apt-get install vlc Ubunt ...
- Python学习笔记(四)——编码和字符串
一.编码 1.编码类别: (1)ASCII码:127个字母被编码到计算机里,也就是大小写英文字母.数字和一些符号 (2)GB2312码:中国制定的用于加入中文汉字的编码 (3)Unicode:防止由于 ...
- elk之elasticsearch 入门
一.概述: 1.查看elasticsearch集群的健康状况: [root@node115 kibana]# curl -X GET http://192.168.39.115:9200/_cat/h ...
- golang 学习笔记 ---Sizeof
unsafe.Sizeof浅析 package main import "unsafe" import "fmt" func main() { slice := ...
- sublime 技巧与快捷键篇
技巧大全:https://www.zhihu.com/question/24896283 项目排除文件夹,更便于ctrl + p的搜索,比如可恶的node_modules "folder ...
- mac 利用 sshpass 自动登录
mac 利用 sshpass + 配置文件 实现自动登录 使用方式 https://github.com/vipzhicheng/go 参见此项目 其实原理也就是 脚本 读取配置文件 匹配 参数或 ...