Modify Mysql-root password under Mac-Solve various permissions problems

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

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

There is also a reference to MySQL installation, with Python-mysql installation blog http://hearrain.com/2011/01/498


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.

If after the installation of MySQL, when you log in with root, you must add--user=mysql, otherwise, the server will automatically create root-owned files, which will lead to permissions issues


I was just logged in, and then the root password without modification permissions, a variety of no permissions


The solution is

kill `cat /mysql-data-directory/host_name.pid`
The path to Mysql-data-directory is typically a PID-terminated file under/usr/local/mysql/data that contains 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 permission, enters MySQL under the bin to enter the above command, after the end (I do 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.





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.