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 |
sudo su mysqld_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
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 |
export DYLD_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