Home > Database > Mysql Tutorial > body text

Detailed explanation of the solution to forgetting the MySQL root password in MACOS

黄舟
Release: 2017-03-23 13:37:10
Original
1182 people have browsed it

This article mainly tells you the actual steps to reset the root password in the MAC system MySQL. It often happens that you forget the MySQL root password in actual operations. The following is the summary of this tutorial. Detailed content introduction.

MySQL is a relational database management system developed by the Swedish MySQL AB company and is currently a product of Oracle. MySQL is one of the most popular relational database management systems. In terms of WEB applications, MySQL is the best RDBMS (Relational Database Management System) application software.

MySQL is a relational database management system. A relational database stores data in different tables instead of placing all data in one large warehouse, which increases speed and flexibility.

The SQL language used by MySQL is the most commonly used standardized language for accessing databases. MySQL software adopts a dual licensing policy and is divided into community version and commercial version. Due to its small size, fast speed, low total cost of ownership, and especially the characteristics of open source, MySQL is generally chosen as the website database for the development of small and medium-sized websites.

After installing MySQL on Mac, the software will generate a default password for us. However, when I use Navicat to establish a connection, it prompts that the password is invalid. I have no choice but to change the database default password.

Next, record the entire root password modification process.

The mysql service must be stopped before starting the following steps!

 cd /usr/local/mysql/bin/
 sudo su
 ./mysqld_safe --skip-grant-tables & //这一步的作用是跨过权限验证
 ./mysql -uroot //以root身份登录,因为第三步的原因不需要密码了。这之后的命令就不需要在前面加./mysql了
 use mysql;
 update user set authentication_string='123456' where User='root';
Copy after login

The versions circulating on the Internet are all set password =‘’. When writing this way, an error is always reported saying that the ‘password’ column does not exist!

Finally, I used the sql command to find out that there is only the authentication_string field and no password field.

After executing the previous step, I thought I could log in, but during the navicat connection test, an error message appeared:

ERROR 1862 (HY000): Your password has expired. To log in you must
change it using a client that supports expired passwords.
Copy after login

So the following steps are needed

 cd /usr/local/mysql/bin/
 sudo su
 ./mysql -uroot -p123456
 set password = password('123456')
Copy after login

Username: root, password :12345

Modification successful

Supplement:Although the above modification was successful, it still took many detours. The above just records the whole process. Below we will The simplest and most effective way to summarize

is that this process is sad. There is so much information on the Internet. The key is that everyone has their own wrong methods. After trying for a long time, no one is right. I am about to break the psychological defense line. When I went to read the MySQL documentation, I made the change successfully. No article gave me the complete answer. I consulted several guides and built the car behind closed doors. Give yourself a thumbs up. Without further ado, just follow me step by step.

1. Close the mysql server

sudo /usr/local/mysql/support-files/mysql.server stop
Copy after login

You can also close it in MySQL in the system preferences.

2.cd /usr/local/mysql/bin Enter the directory

##3.sudo su Obtain permissions

4. ./mysqld_safe --skip-grant-tables & Restart the server

5. Reopen a terminal,

Configuration short command:

alias mysql=/usr/local/mysql/bin/mysql
Copy after login
6. Enter mysql to enter mysql

command mode

7.use mysql to enter

mysql database

8.

flush privileges;Probably just get the permissions, otherwise he won’t let you change it.

9.

set password for 'root'@'localhost'=password('new password'); Complete the modification

10.I Damn it’s finally done.

The above is the detailed content of Detailed explanation of the solution to forgetting the MySQL root password in MACOS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!