在雪豹上brew安装mysql不太工作

发布于 2024-10-21 16:22:01 字数 5806 浏览 0 评论 0原文

我通过brew安装了mysql,看起来安装顺利。 Mysql 不会让我设置 root 密码,即使我变得很狡猾。看起来好像表格完全丢失了。 详细输出如下。

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)

疯狂的结果...

我确保我拥有 usr/local:

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> 

到底是什么,这不应该影响一行吗?好像桌子没做好? 我应该使用 sudo 运行 mysql_install_db 吗?

PS:我可能把这一切都归咎于我自己,傲慢地忽略了brew公式在下载mysql-5.1.54时失败并将其编辑为dl 5.1.55。但是,除此之外,你还能看出我在这里做错了什么吗?

编辑: 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

I installed mysql via brew, looks like the install went ok. Mysql will not let me set root password, even if I get tricky. Appears as though tables are missing altogether.
Detailed output below.

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 ENSUING...

I made sure I owned usr/local:

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

I even tried starting mysql with 'skip grant tables' and setting the password:

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

Then in another terminal window:

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> 

What the heck, shouldn't that affect a row? It is like the tables did not get made?
Should I have ran mysql_install_db with sudo?

PS: I probably brought this all on myself by cavalierly ignoring that the brew formula failed on downloading mysql-5.1.54 and I edited it to dl 5.1.55. But, aside from that, is there anything you can see that I have done wrong here?

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

indicate a couple of mysql queries to create the root user on the mysql.user table.
Those queries don't work for me, I get an error.

    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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

多情出卖 2024-10-28 16:22:01

看起来用户表没有正确创建。您应该以 root 用户身份运行 mysql_install_db,因为您可能没有 /usr/local/var/mysql/ 的写入权限

Looks like user table wasn't created properly. You should run mysql_install_db as a root user as probably you don't have a write access to /usr/local/var/mysql/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文