2011-03-14 134 views
3

我通过BREW mysql安装mysql的,看起来像安装就ok了。即使我变得棘手,Mysql也不会让我设置root密码。似乎表格完全丢失。 以下详细输出。BREW上安装雪豹不太工作

jb:~ jb$ brew install mysql 
==> Downloading http://mysql.mirrors.pair.com/Downloads/MySQL-5.1/mysql-5.1.55.tar.gz 
######################################################################## 100.0% 
==> Downloading patches 
==> Patching 
patching file scripts/mysqld_safe.sh 
Hunk #1 succeeded at 384 (offset 1 line). 
patching file scripts/mysql_config.sh 
==> ./configure --without-docs --without-debug --disable-dependency-tracking --prefix=/usr/local/Cellar/mysql/5.1.55 --l 
==> make install 
==> Caveats 
Set up databases with: 
    unset TMPDIR 
    mysql_install_db 

If this is your first install, automatically load on login with: 
    mkdir -p ~/Library/LaunchAgents 
    cp /usr/local/Cellar/mysql/5.1.55/com.mysql.mysqld.plist ~/Library/LaunchAgents/ 
    launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist 

If this is an upgrade and you already have the com.mysql.mysqld.plist loaded: 
    launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist 
    cp /usr/local/Cellar/mysql/5.1.55/com.mysql.mysqld.plist ~/Library/LaunchAgents/ 
    launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist 

Note on upgrading: 
    We overwrite any existing com.mysql.mysqld.plist in ~/Library/LaunchAgents 
    if we are upgrading because previous versions of this brew created the 
    plist with a version specific program argument. 

Or start manually with: 
    mysql.server start 
==> Summary 
/usr/local/Cellar/mysql/5.1.55: 220 files, 42M, built in 17.6 minutes 
jb:~ jb$ echo $TMPDIR 
/var/folders/uL/uLRuoWTeFi86v2TkZkknLU+++TI/-Tmp-/ 
jb:~ jb$ unset TMPDIR 
jb:~ jb$ echo $TMPDIR 

jb:~ jb$ mysql_install_db 
Installing MySQL system tables... 
OK 
Filling help tables... 
OK 

To start mysqld at boot time you have to copy 
support-files/mysql.server to the right place for your system 

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! 
To do so, start the server, then issue the following commands: 

/usr/local/Cellar/mysql/5.1.55/bin/mysqladmin -u root password 'new-password' 
/usr/local/Cellar/mysql/5.1.55/bin/mysqladmin -u root -h jb.local password 'new-password' 

Alternatively you can run: 
/usr/local/Cellar/mysql/5.1.55/bin/mysql_secure_installation 

which will also give you the option of removing the test 
databases and anonymous user created by default. This is 
strongly recommended for production servers. 

See the manual for more instructions. 

You can start the MySQL daemon with: 
cd /usr/local/Cellar/mysql/5.1.55 ; /usr/local/Cellar/mysql/5.1.55/bin/mysqld_safe & 

You can test the MySQL daemon with mysql-test-run.pl 
cd /usr/local/Cellar/mysql/5.1.55/mysql-test ; perl mysql-test-run.pl 

Please report any problems with the /usr/local/Cellar/mysql/5.1.55/bin/mysqlbug script! 

jb:~ jb$ cp /usr/local/Cellar/mysql/5.1.55/com.mysql.mysqld.plist ~/Library/LaunchAgents/ 
jb:~ jb$ launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist 
jb:~ jb$ /usr/local/Cellar/mysql/5.1.55/bin/mysql_secure_installation 




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL 
     SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! 


In order to log into MySQL to secure it, we'll need the current 
password for the root user. If you've just installed MySQL, and 
you haven't set the root password yet, the password will be blank, 
so you should just press enter here. 

Enter current password for root (enter for none): 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 

MADNESS随后...

我确信我拥有USR /本地:

jb:~ jb$ sudo chown -R `whoami` /usr/local 
jb:~ jb$ which mysql 
/usr/local/bin/mysql 

我甚至尝试启动MySQL用 '跳过授权表',并设置密码:

jb:~ jb$ launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist 
jb:~ jb$ killall mysqld 
No matching processes belonging to you were found 
jb:~ jb$ mysqld_safe --skip-grant-tables 
110314 15:09:01 mysqld_safe Logging to '/usr/local/var/mysql/jb.local.err'. 
110314 15:09:01 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql 

然后在另一个终端窗口中:

jb:~ jb$ mysql -u root 
Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 1 
Server version: 5.1.55 Source distribution 

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 
This software comes with ABSOLUTELY NO WARRANTY. This is free software, 
and you are welcome to modify and redistribute it under the GPL v2 license 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 

mysql> UPDATE mysql.user SET Password=PASSWORD('pretend_strong_password_here') WHERE User='root'; FLUSH PRIVILEGES; 
Query OK, 0 rows affected (0.02 sec) 
Rows matched: 0 Changed: 0 Warnings: 0 

Query OK, 0 rows affected (0.03 sec) 

mysql> 

见鬼,不应该影响一个行?这就像桌子没有被制造出来一样? 我应该已经跑mysql_install_dbsudo

PS:我可能是傲慢无视冲泡配方失败的下载的mysql-54年1月5日,我编辑它延胡索55年5月1日带来这一切我自己。但是,除此之外,有什么可以看到我在这里做错了吗?

编辑: http://forums.mysql.com/read.php?10,277700,280261#msg-280261http://palmeradev.blogspot.com/2010/12/fix-bug-mysql-root-user-not-created.html

表示一对夫妇的MySQL查询来创建mysql.user表中的root用户。 这些查询不适用于我,我得到一个错误。

mysql> INSERT INTO user VALUES ('localhost','root',password('newpassword'),'Y','Y ','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y', 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','' ,'','','',0,0,0,0); 
ERROR 1136 (21S01): Column count doesn't match value count at row 1 
+0

你的代码看起来真吓人!尝试并缩短它或什么......没有多少人可能想要回答所有那些疯狂随之而来!? ;) – gideon 2011-03-14 08:42:29

+0

谢谢,吉迪。如果我能够自己缩小问题的范围,我会削减更多终端输出。我希望在这里的某个地方,我的面前答案是正确的。 – 2011-03-14 10:01:15

+0

你的'用户'表有根吗?即,如果您运行'select * from user;'你看到什么了吗? – zlog 2011-04-01 05:38:10

回答

1

看起来像用户表没有被正确创建。你应该以root用户运行mysql_install_db因为可能你没有到/ usr /本地的/ var/mysql的写访问/