brew instaluje mysql na mac os

Próbuję skonfigurować MySQL na mac os 10.6 używając Homebrew by brew install mysql 5.1.52.

Wszystko idzie dobrze, a ja również odniosłem sukces z mysql_install_db.
Jednak gdy próbuję połączyć się z serwerem za pomocą:

/usr/local/Cellar/mysql/5.1.52/bin/mysqladmin -u root password 'mypass'

Otrzymuję:

/usr/local/Cellar/mysql/5.1.52/bin/mysqladmin: connect to server at 'localhost' 
failed error: 'Access denied for user 'root'@'localhost' (using password: NO)'

Próbowałem również uzyskać dostęp mysqladmin or mysql using -u root -proot,
ale to nie działa z lub bez hasła.

Jest to zupełnie nowa instalacja na zupełnie nowej maszynie i o ile wiem, nowa instalacja musi być dostępna bez hasła roota. I próbowano też:

/usr/local/Cellar/mysql/5.1.52/bin/mysql_secure_installation

Ale ja też dostaję

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Author: guaka, 2010-12-05

14 answers

Myślę, że można skończyć w tej pozycji ze starszymi wersjami mysql już zainstalowane. Miałem ten sam problem i Żadne z powyższych rozwiązań nie zadziałało na mnie. Naprawiłem to tak:

Używane Browary remove & cleanup w tym celu należy uruchomić skrypt launchctl, a następnie usunąć katalog mysql w /usr/local/var, usunąć mój istniejący /etc/my.cnf (pozostawić ten jeden do ciebie, jeśli ma zastosowanie) i launchctl plist

Zaktualizowano ciąg dla plist. Uwaga również Twój alternatywny katalog skryptów bezpieczeństwa będzie na podstawie której wersji MySQL instalujesz.

Krok po kroku:

brew remove mysql

brew cleanup

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

sudo rm -rf /usr/local/var/mysql

Zacząłem od zera:

  1. zainstalowany mysql z brew install mysql
  2. Uruchomił polecenia brew sugerowane: (patrz uwaga: poniżej)

    unset TMPDIR
    
    mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
    
  3. Uruchom mysql za pomocą polecenia mysql.server start, aby móc się na nim zalogować

  4. Użyto alternatywnego skryptu bezpieczeństwa:

    /usr/local/Cellar/mysql/5.5.10/bin/mysql_secure_installation
    
  5. Po sekcji launchctl ze skryptu pakietu brew wynik taki as,

    #start
    launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
    
    #stop
    launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
    
  6. Bum.

Mam nadzieję, że to komuś pomoże!

Uwaga: bit --force na brew cleanup będzie również czyścił przestarzałe beczki, myśląc, że jest to nowa funkcja homebrew.

Uwaga druga: komentator mówi, że krok 2 nie jest wymagany. Nie chcę tego testować, więc YMMV!

 605
Author: Lorin Rivers,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-09-19 14:40:54

Miałem ten sam problem. Wydaje się, że coś jest nie tak z instrukcjami konfiguracji lub początkowymi tabelami, które są tworzone. W ten sposób mam mysqld uruchomiony na moim komputerze.

Jeśli serwer mysqld jest już uruchomiony na komputerze Mac, zatrzymaj go najpierw za pomocą:

launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist

Uruchom serwer mysqld za pomocą następującego polecenia, które pozwala każdemu zalogować się z pełnymi uprawnieniami.

mysqld_safe --skip-grant-tables

Następnie uruchom mysql -u root który powinien teraz pozwolić Ci zalogować się pomyślnie bez hasło. Poniższe polecenie powinno zresetować wszystkie hasła główne.

UPDATE mysql.user SET Password=PASSWORD('NewPassword') WHERE User='root'; FLUSH PRIVILEGES;

Teraz, jeśli zabijesz uruchomioną kopię mysqld_safe i uruchomisz ją ponownie bez opcji skip-grant-tables, powinieneś być w stanie zalogować się za pomocą mysql -u root -p i nowego hasła, które właśnie Ustawiłeś.

 42
Author: Alistair McMillan,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-01-07 23:30:54

Oto szczegółowe instrukcje łączące pozbycie się wszystkich MySQL z komputera Mac, a następnie zainstalowanie go w sposób Brew jak Sedorner napisał powyżej:

Usuń MySQL całkowicie na Laboratorium techniczne

  • ps -ax | grep mysql
  • stop i kill wszelkie procesy MySQL
  • sudo rm /usr/local/mysql
  • sudo rm -rf /usr/local/var/mysql
  • sudo rm -rf /usr/local/mysql*
  • sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
  • sudo rm -rf /Library/StartupItems/MySQLCOM
  • sudo rm -rf /Library/PreferencePanes/My*
  • launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
  • edytuj /etc/hostconfig i Usuń wiersz MYSQLCOM=-YES-
  • rm -rf ~/Library/PreferencePanes/My*
  • sudo rm -rf /Library/Receipts/mysql*
  • sudo rm -rf /Library/Receipts/MySQL*
  • sudo rm -rf /private/var/db/receipts/*mysql*
  • spróbuj uruchomić mysql, nie powinno działać

Brew install MySQL per user Sedorner from this StackOverflow answer

  • brew doctor i naprawić wszelkie błędy
  • brew remove mysql
  • brew cleanup
  • brew update
  • brew install mysql
  • unset TMPDIR
  • mysql_install_db --verbose --user= whoami --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
  • mysql.server start
  • uruchom polecenia, Dodaj MySQL do launchctl więc automatycznie uruchamia się przy starcie

mysql powinien teraz działać i działać przez cały czas zgodnie z oczekiwaniami]} Z Bogiem.

 41
Author: corysimmons,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 12:10:45

Jeśli brew zainstalował MySQL 5.7, Proces jest nieco inny niż w poprzednich wersjach. Aby zresetować hasło roota, postępuj w następujący sposób:

sudo rm -rf /usr/local/var/mysql
mysqld --initialize

Tymczasowe hasło zostanie wydrukowane na konsoli i może być użyte tylko do aktualizacji hasła głównego:

mysql.server start
echo "ALTER USER 'root'@'localhost' IDENTIFIED BY 'my-new-password';" | mysql -uroot -pTEMPORARY_PASSWORD
 11
Author: mrucci,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-11-25 19:11:49

Miałem ten sam problem i go rozwiązałem. Z jakiegoś powodu Skrypt mysql_secure_installation nie działa po wyjęciu z pudełka, gdy używasz Homebrew do instalacji mysql, więc zrobiłem to ręcznie. w CLI wpisz :

mysql -u root

To powinno wprowadzić cię do mysql. Teraz wykonaj następujące czynności (pobrane z mysql_secure_installation):

UPDATE mysql.user SET Password=PASSWORD('your_new_pass') WHERE User='root';
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
DELETE FROM mysql.user WHERE User='';
DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'
DROP DATABASE test;
FLUSH PRIVILEGES;

Teraz wyjdź i wróć do mysql z: mysql -u root -p

 8
Author: Darren Newton,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-12-26 05:03:14

Właśnie miałem ten sam problem. Jeśli brew info mysql i wykonaj kroki, wygląda na to, że hasło roota powinno być new-password, jeśli dobrze pamiętam. Widziałem to samo, co Ty. Ten artykuł pomógł mi najbardziej.

Okazało się, że nie mam żadnych stworzonych dla mnie kont. Gdy zalogowałem się po uruchomieniu mysqld_safe i zrobiłem select * from user; żadne wiersze nie zostały zwrócone. Otworzyłem MySQLWorkbench z uruchomionym mysqld_safe i dodałem konto root ze wszystkimi privami, których oczekiwałem. Teraz mi to dobrze wychodzi.

 8
Author: Mark,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-01-07 04:18:54

Jeśli mysql jest już zainstalowany

Całkowicie Zatrzymaj mysql.

  1. mysql.server stop
  2. ps -ef | grep mysql
  3. kill [PID]

Usuń pliki. Powyższe instrukcje są dobre. Dodam:

  1. sudo find /. -name "*mysql*"
  2. Używając Twojego osądu, te pliki. Zauważ, że wiele programów posiada sterowniki dla mysql, których nie chcesz usuwać. Na przykład: nie usuwaj rzeczy z katalogu instalacji PHP. Czy usunąć rzeczy we własnym katalogu mysql.

Zainstaluj

Mam nadzieję, że masz homebrew. Jeśli nie, pobierz go.

Lubię podawać napar jako korzeń, ale chyba nie musisz. Edycja 2018: nie możesz już uruchamiać brew jako root

  1. sudo brew update
  2. sudo brew install cmake
  3. sudo brew install openssl
  4. sudo brew info mysql
  5. sudo brew install mysql --with-embedded; say done

Potem

  1. sudo chown -R mysql /usr/local/var/mysql/
  2. sudo mysql.server start
  3. Tworzenie użytkowników w mysql ( http://dev.mysql.com/doc/refman/5.7/en/create-user.html ). pamiętaj, aby dodać hasło dla użytkownika root.
 6
Author: sudo rm -rf slash,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-08-05 10:34:55

Brew info mysql

mysql: stable 5.6.12 (bottled)
http://dev.mysql.com/doc/refman/5.6/en/
Conflicts with: mariadb, mysql-cluster, percona-server
/usr/local/Cellar/mysql/5.6.12 (9363 files, 353M) *
  Poured from bottle
From: https://github.com/mxcl/homebrew/commits/master/Library/Formula/mysql.rb
==> Dependencies
Build: cmake
==> Options
--enable-debug
    Build with debug support
--enable-local-infile
    Build with local infile loading support
--enable-memcached
    Enable innodb-memcached support
--universal
    Build a universal binary
--with-archive-storage-engine
    Compile with the ARCHIVE storage engine enabled
--with-blackhole-storage-engine
    Compile with the BLACKHOLE storage engine enabled
--with-embedded
    Build the embedded server
--with-libedit
    Compile with editline wrapper instead of readline
--with-tests
    Build with unit tests
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.

To connect:
    mysql -uroot

To reload mysql after an upgrade:
    launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

Mysql.start serwisu

. ERROR! The server quit without updating PID file (/var/run/mysqld/mysqld.pid).

Lub mysql-u root

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Szukam rozwiązania na jakiś czas, ale nie mogę rozwiązać mojego problemu. Wypróbowałem kilka rozwiązań w stackoverflow.com ale to mi nie pomaga.

 3
Author: Felipe Duardo,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-07-27 23:09:48

TL; DR

Serwer MySQL może nie być uruchomiony po instalacji z Brew. Spróbuj brew services start mysql lub po prostu mysql.server start, jeśli nie chcesz, aby MySQL działał jako usługa w tle.

Pełna Wersja:

Właśnie zainstalowałem MySQL (stable) 5.7.17 na nowym MacBooku Pro z uruchomieniem Sierra i również dostałem błąd podczas działania mysql_secure_installation:

Securing the MySQL server deployment.

Enter password for user root: 
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

że co?

Zgodnie z informacją o instalacji z Brew, mysql_secure_installation powinno mnie skłonić do... zabezpiecz instalację. I pomyślałem, że serwer MySQL może nie być uruchomiony i słusznie. Bieganie brew services start mysql, a następnie mysql_secure_installation działało jak czar.

 2
Author: Nicholas,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-01-16 21:21:24

Spróbuj podając polecenie Grant permission mysql

 1
Author: XMen,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-12-05 14:12:09

Żadna z powyższych odpowiedzi (ani żadna z dziesiątek odpowiedzi, które widziałem gdzie indziej) nie zadziałała dla mnie, gdy używałem brew z najnowszą wersją mysql i yosemite. Skończyło się na zainstalowaniu innej wersji mysql przez brew.

Określenie starszej wersji przez wyrażenie (na przykład)

brew install mysql56
Zadziałało dla mnie. Mam nadzieję, że to komuś pomoże. To był frustrujący problem, który czułem, jakbym utknął na zawsze.
 1
Author: toddmetheny,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-11-22 22:53:15

Miałem ten sam problem po próbie ponownego uruchomienia mysql.

Używam następujących dwóch aliasów w moim .profil dla wygody

alias mysql-stop='launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist'
alias mysql-start='launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist' 

Po zatrzymaniu mysql, a następnie próbie ponownego uruchomienia, doświadczyłem problemu, który miałeś. Spojrzałem na ładowanie launchctl i zgłaszało błąd "nic nie znaleziono do załadowania".

Po szybkim przeszukaniu znalazłem to..

Http://www.daveoncode.com/2013/02/01/solve-mac-osx-launchctl-nothing-found-to-load-error/

Więc zaktualizowałem Mi mysql-start alias w następujący sposób

alias mysql-start='launchctl load -w -F ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist'
To rozwiązało mój problem, który może być dla Ciebie przydatny.
 0
Author: Alexander Millar,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-08-09 13:00:30

"Base-Path" dla Mysql jest przechowywany w /etc/my.cnf, który nie jest aktualizowany podczas aktualizacji brew. Po prostu otwórz go i zmień wartość basedir

Na przykład zmień to:

[mysqld]
basedir=/Users/3st/homebrew/Cellar/mysql/5.6.13

Aby wskazać nową wersję:

[mysqld]
basedir=/Users/3st/homebrew/Cellar/mysql/5.6.19

Restart mysql z:

mysql.server start
 0
Author: Bernhard Zürn,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-11-25 19:20:02

Oto aktualizacja dla MySQL 5.7

bash --version
GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin17.0.0)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

#========================================
brew --version
Homebrew 1.7.6
Homebrew/homebrew-core (git revision eeb08; last commit 2018-09-27)
Homebrew/homebrew-cask (git revision c9f62; last commit 2018-09-27)

#========================================
mysql --version
mysql  Ver 14.14 Distrib 5.7.23, for osx10.13 (x86_64) using  EditLine wrapper

#========================================
system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: macOS 10.13.3 (17D47)
      Kernel Version: Darwin 17.4.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name: EdisonMacHomeBj
      User Name: Edison (edison)
      Secure Virtual Memory: Enabled
      System Integrity Protection: Disabled
      Time since boot: 6 days 23:13
brew remove [email protected]
brew cleanup
mv /usr/local/var/mysql /usr/local/var/mysql.bak
brew install [email protected]
rm -rf /usr/local/var/mysql

#========================================
mysqld --initialize
2018-09-28T04:54:06.526061Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-09-28T04:54:06.542625Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2018-09-28T04:54:07.096637Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-09-28T04:54:07.132950Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-09-28T04:54:07.196824Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 87cf2f10-c2da-11e8-ac2d-ba163df10130.
2018-09-28T04:54:07.224871Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-09-28T04:54:07.366688Z 0 [Warning] CA certificate ca.pem is self signed.
2018-09-28T04:54:07.457954Z 1 [Note] A temporary password is generated for root@localhost: kq3K=JR8;GqZ

#========================================
mysql_secure_installation -uroot -p"kq3K=JR8;GqZ"
mysql_secure_installation: [Warning] Using a password on the command line interface can be insecure.

Securing the MySQL server deployment.


The existing password for the user account root has expired. Please set a new password.

New password:

Re-enter new password:

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: n
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y

New password:

Re-enter new password:
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : n

 ... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done!
 0
Author: Edison,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-09-28 07:05:44