Modify mysql under mac

Source: Internet
Author: User
Tags mysql login
Official information: dev.mysql.comdocrefman5.0enresetting-permissions.html # resetting-permissions-unix also has a reference to mysql installation, with python-mysql installation blog hearrain. com201101498 according to the official documentation, Forexample, ifyouruntheserverusin

Official information: http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html#resetting-permissions-unix also has a reference to mysql installation, with python-mysql installation blog http://hearrain.com/2011/01/498 according to the official documentation, For example, if you run the server usin

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

There is also a reference for 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, but in this case you must start mysqld with the --user=mysql option. If you start the server as root without using --user=mysql, the server may create root-owned files in the data directory, such as log files, and these may cause permission-related problems for future server startups.

After installing mysql, if you use root to log on, you must add -- user = mysql. Otherwise, the server will automatically create the root-owned file, these will cause permission issues.


I used to log on directly, and the root password has no permission to modify.


The solution is

shell> kill `cat /mysql-data-directory/host_name.pid`
The mysql-data-directory path is generally a file with a pid ending with your computer name under/usr/local/mysql/data.


UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';FLUSH PRIVILEGES;
After the process ends, put the preceding two sentences in a file, for example, update_passwd. The file is under/usr/local /.


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

Then sudo su enters the root permission, enters the bin of mysql, and enters the preceding command. After the command is completed (if my command is not completed, another terminal is enabled ),

Go to the mysql Command Line

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

Then, it will be OK.

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.