Newly installed MySQL under Mac cannot log on to root user solution

Source: Internet
Author: User
Tags gz file

I do not know why, the newly installed MySQL, if you try to log in with Mysql-u root-p This error will occur, but the root user did not set the password.
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)

Here's the solution:
1. Turn off the MySQL service in System Preferences first;
2. Enter in the terminal

12 sudosumysqld_safe --skip-grant-tables --skip-networking &

Then you can go over the permission table and log in to MySQL directly.
3. Create a new terminal, enter

1 mysql -u root

4. Modify the root user password in MySQL:

12 mysql> UPDATE mysql.user SET password=PASSWORD(’新密码’) WHERE User=’root’;mysql> FLUSH PRIVILEGES;

Here's how to install MySQLdb on your Mac:
Because MySQL is used in Python, there is no MySQL operation in Python's built-in library. So you have to install a separate one, before installing the following content you first have to load a MySQL.
Download MySQLdb for Python here, now the latest version is 1.2.3, download the mysql-python-1.2.3.tar.gz file. (large windows directly Mysql-python-1.2.3.win32-py2.7.msi installation)

After the Finder directly double-clicks the tarball or $tar ZXVF unzip, open the Site.cfg file inside to find this line:

1 #mysql_config = /usr/local/bin/mysql_config

Modify the location of your actual installed MySQL, you can $cd all the way. To see, mine is:

1 mysql_config = /usr/local/mysql/bin/mysql_config

Then $cd into the unpacked directory input $python setup.py Build, note that this operation before you make sure that GCC or xcode+command line tools is already installed on your Mac.
Again $sudo python setup.py install, installation is complete, but you import mysqldb a lot of errors will appear. This time you $ls-al in the user directory and then open the $open. bash_profile file to add the following

1 exportDYLD_LIBRARY_PATH="/usr/local/mysql/lib"

Then perform $sudo ln-s on the terminal/usr/local/mysql/lib/libmysqlclient.18.dylib/usr/lib/libmysqlclient.18.dylib

ps:http://www.euryugasaki.com/archives/853

Newly installed MySQL under Mac cannot log on to root user solution

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.