Mac is changing mysql-rootpassword-ability to solve various problems

Source: Internet
Author: User
Tags mysql command line mysql login

Official data: Http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html#resetting-permissions-unix

Another value gets the reference to the MySQL device. http://hearrain.com/2011/01/498 with Python-mysql Pack blog


According to official documents.

For example, if you run the server using the MySQL login account, you should log in as MySQL before using the instructions . Alternatively, you can log in as root, and if you must start mysqld with the--user=mysql option. If you start the server as root without using--user=mysql, the server could create root-owned files in the data directory, such as log files, and these may cause permission-related problems for the future server startups.

Let's say that after MySQL is installed, when you log in with root. Must add--user=mysql, otherwise, the server will voluntarily create the root-owned file, which will lead to the issue of permissions


I have been directly logged in, and then Rootpassword no change permissions, a variety of no permissions


The solution is

kill `cat /mysql-data-directory/host_name.pid`
The path to the mysql-data-directory is usually a PID-terminated file under/usr/local/mysql/data that includes your computer's name.


UPDATE mysql.user SET password=password (' Mynewpass ') WHERE user= ' root '; FLUSH privileges;
After the process is finished, put the above two sentences into a file such as UPDATE_PASSWD, the file under/usr/local/


mysqld_safe --init-file=/home/me/mysql-init &

Then sudo su enters root, enters MySQL under the bin to enter the above command, after the end (I did not seem to end, opened another terminal).

Go to the MySQL command line

UPDATE mysql.user SET Password=PASSWORD(‘MyNewPass‘)-WHERE User=‘root‘;

And then it's OK to go in again.





Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

Mac is changing mysql-rootpassword-ability to solve various problems

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.