Home Database Mysql Tutorial Ubuntu下MySQL的'Access denied for user 'root'@'localhost' (usi

Ubuntu下MySQL的'Access denied for user 'root'@'localhost' (usi

Jun 07, 2016 pm 05:33 PM
mysql error

我的环境是xubuntu 12.10下apt-get安装mysql,登陆无法登陆,报错信息这样描述:在用命令(sudo apt-get install mysql-server mys

问题现象:
我的环境是xUbuntu 12.10下apt-get安装mysql,登陆无法登陆,报错信息这样描述:在用命令(sudo apt-get install mysql-server mysql-client)安装完.mysql服务即开始运行了.此时需要修改root密码,但经常会出现这么一种情况.'Access denied for user 'root'@'localhost' (using password: YES)' 或者其他致使无法登录mysql的情况。

解决方法:
1.打开/etc/mysql/debian.cnf文件,里面存储了相关的密码,我的文件信息如下

sudovi /etc/mysql/debian.cnf# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = 6x1XG2B5p75WtFV2
socket = /var/run/mysqld/mysqld.sock

[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = 6x1XG2B5p75WtFV2
socket = /var/run/mysqld/mysqld.sock
basedir = /usr

在[client]段有user=以及password=这两行,这就是通过apt-get安装mysql,系统给我们设置的mysql登录名和密码

2. 输入命令:
mysql -udebian-sys-maint -pdebian-sys- maint即debian.cnf中user=后面的内容.回车后会提示输入密码,,此时把password=后面的内容复制粘贴后回车即可进行mysql 控制台


3.进入控制台后.按以下步骤进行:
use mysql;update user set password=PASSWORD('新密码') where user='root';FLUSH PRIVILEGES;此时可以输入quit;退出后用root帐号登录,也可以继续其他操作.

相关阅读:

ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql    与

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 

MySQL无lock tables权限 报Access denied for user when using LOCK TABLES 

gentoo下运行mysql提示Access denied for user 'root'@'localhost'错误的解决 

linux

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to deal with MySQL connection error 1049? How to deal with MySQL connection error 1049? Jun 29, 2023 am 09:50 AM

How to deal with MySQL connection error 1049? MySQL is a commonly used relational database management system. Many developers and system administrators use MySQL to store and manage data. However, when using MySQL, sometimes you encounter the problem of connection error 1049. This article will introduce the causes of connection error 1049 and give several methods to solve this problem. MySQL connection error 1049 is usually caused by the database not existing or the database name being wrong. When connecting to the MySQL service

Unknown column 'column_name' in 'field list' - How to solve MySQL error: unknown column in field list Unknown column 'column_name' in 'field list' - How to solve MySQL error: unknown column in field list Oct 05, 2023 am 10:44 AM

Title: Unknowncolumn'column_name'in'fieldlist'-How to solve MySQL error: Unknown column in field list, specific code examples are needed. When using the MySQL database for query or operation, sometimes you will encounter such error message: "Unknowncolumn' column_name'in'fieldlist'", that is, an unknown column error exists in the field list. This is usually

How to solve mysql database initialization failure How to solve mysql database initialization failure Apr 14, 2024 pm 07:12 PM

To resolve the MySQL database initialization failure issue, follow these steps: Check permissions and make sure you are using a user with appropriate permissions. If the database already exists, delete it or choose a different name. If the table already exists, delete it or choose a different name. Check the SQL statement for syntax errors. Confirm that the MySQL server is running and connectable. Verify that you are using the correct port number. Check the MySQL log file or Error Code Finder for details of other errors.

What to do if MySQL connection error 1017 occurs? What to do if MySQL connection error 1017 occurs? Jun 30, 2023 am 11:57 AM

How to deal with MySQL connection error 1017? MySQL is an open source relational database management system that is widely used in website development and data storage. However, when using MySQL, you may encounter a variety of errors. One of the common errors is connection error 1017 (MySQL error code 1017). Connection error 1017 indicates a database connection failure, usually caused by an incorrect username or password. When MySQL fails to authenticate using the provided username and password

PHP returns the numeric encoding of the error message in the previous MySQL operation PHP returns the numeric encoding of the error message in the previous MySQL operation Mar 22, 2024 pm 12:31 PM

This article will explain in detail the numerical encoding of the error message returned by PHP in the previous Mysql operation. The editor thinks it is quite practical, so I share it with you as a reference. I hope you can gain something after reading this article. . Using PHP to return MySQL error information Numeric Encoding Introduction When processing mysql queries, you may encounter errors. In order to handle these errors effectively, it is crucial to understand the numerical encoding of error messages. This article will guide you to use php to obtain the numerical encoding of Mysql error messages. Method of obtaining the numerical encoding of error information 1. mysqli_errno() The mysqli_errno() function returns the most recent error number of the current MySQL connection. The syntax is as follows: $erro

How to check the progress of MySQL database recovery How to check the progress of MySQL database recovery Feb 24, 2024 pm 12:24 PM

MySQL is a very commonly used open source relational database management system. It has the characteristics of stability, efficiency, flexibility, etc., and is widely used in various types of applications. When using MySQL, you will inevitably encounter database recovery operations. How to accurately check the progress of MySQL database recovery has become a more important issue. The recovery progress of the MySQL database can be obtained by viewing the MySQL error log. In the MySQL error log, all database operation records will be recorded.

How to solve MySQL error 1171 How to solve MySQL error 1171 Jan 09, 2024 pm 03:59 PM

Solution: 1. Check the data types to ensure that the data types in the columns you create or modify the index are compatible; 2. Avoid using functions or expressions on the columns where you create the index; 3. Use explicit type conversion. If you must use functions or expressions on indexed columns, make sure you use explicit type conversion. 4. Check the MySQL version and documentation to learn more about indexes and data types. 5. Optimize queries , consider re-evaluating and optimizing your queries to ensure effective use of indexes; 6. Consider using other tools or methods, etc.

Collection of solutions to common MySQL errors Collection of solutions to common MySQL errors Jun 15, 2023 pm 02:58 PM

During development, if you often deal with MySQL, you will encounter some common errors. Some errors will cause MySQL to not work properly, and some will affect the performance of the program. Here are some common MySQL errors and their solutions. MySQL server cannot connect. When connecting to the MySQL server, you may encounter the following error: Can'tconnecttoMySQLserveron'localhost'(10061)Ac

See all articles