Using HomeBrew to install MySQL - mysql

I have MySQL stable 8.0.19 (bottled) installed via mac HomeBrew:
brew install mysql
and it asks me to follow these instructions in the Caveat section:
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
To have launchd start mysql now and restart at login:
brew services start mysql
Or, if you don't want/need a background service you can just run:
mysql.server start
and when I run the mysql_secure_installation command with or without sudo I get:
Securing the MySQL server deployment.
Enter password for user root:
Now I tried looking for the default password. The MySQL installation process for macOS here shows that on the last step a temporary password is provided for the user:
[][5]
(source: [mysql.com](https://dev.mysql.com/doc/mysql-osx-excerpt/5.7/en/images/mac-installer-root-password.png))
However, I do not see any information about a temporary password within the HomeBrew terminal outputs. From here I tried:
sudo grep 'temporary password' /var/log/mysqld.log
but I get:
grep: /var/log/mysqld.log: No such file or directory
then I tried looking for that log file:
sudo find / -name mysqld.log
but I get lots of find: ... Operation not permitted instead of any meaningfull results.
I would appreciate if you could help me know
if I have done everything correctly so far,
if not what mistakes I have made and how to fix them
if yes how I can acquire the temporary password
what are the next steps
Ideally, I should be able to follow the rest of this tutorial within the GUI.

Ok, I think I had some progress. I ran
brew services list
and it showed that mysql stopped, now I ran:
brew services start mysql
now the mysql_secure_installation script ran smoothly with
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
helping me set up a password and other settings. Now you may install the MySQL Workbench (the GUI seen in the tutorial) by:
brew cask install mysqlworkbench
and you should be able to find and run MYSQLWorkbench from your /Applications/ folder!
P.S. Wrote simple instructions here.

For macOS users, there is DBngin (https://dbngin.com) that gives
you push-button start/stop for MySql, PostgreSQL (and redis) .. different
versions with non-overlapping config/data directories.
Really saves me - and my students! - in my DB course.

Related

Access Denied for User 'root'#'localhost' (using password: YES) or (using password: NO)?

I have installed mysql in mac big sur using homebrew as
brew install mysql
But during the
GRANT ALL PRIVILEDGE
I mistakenly gave some other password to root and thus not able to start mysql again.
Tried all the steps/ suggestions for this question all over stack-overflow and blogs but did not get full steps anywhere (probably I might have missed it somewhere)
I tried to stop mysql and then start with --skip-grant-tables but it is still giving me same error for the second command.
Tried uninstalling and reinstalling but upto no progress so far
By going through multiple answers I found this steps which worked for me
Mac OS : Big Sur 11.6.8
MySQL : 8.0.30
Steps:
Uninstall mysql. (In my case I am using homebrew)
brew uninstall mysql
Reinstall mysql
brew install mysql
Goto path and open the file in editor
/usr/local/etc/my.cnf
Copy this in the file
[mysqld]
skip-grant-tables
(You might already have the "mysqld" section so just add the line below it)
Goto terminal
Stop mysql service if running
mysql.server stop
Run the command
mysqld_safe --skip-grant-tables --skip-syslog --skip-networking
Start mysql as you won't have to enter password again now
mysql -u root

Not able to run mysql 8.0.12 as root on macOS

I have downloaded macOS 10.13 (x86, 64-bit), DMG Archive and install it on my Mac(10.13.6) but while accessing it in terminal it's not taking root password which I have set during the installation process.
I have checked system preference MySQL is running and trying to access MySQL by below command, though it's asking for the password but not taking it after trying it, its giving below error
sudo /user/local/mysql -u root -p
error : sudo: /user/local/mysql: command not found
You didn't install mysql there. Double-check where it's actually installed. You'll probably be able to use plain old mysql as the command name.

Access denied for user 'root'#'localhost'

I went through all similar or identical questions (this and this, for ex.) but still can't solve the problem.
I am on Xenial and have MySQL 5.7.12. I do not remember setting any password during installation (if it asked, I provided empty one).
I tried to go through password reset using --skip-grant-tables, as described here, it updated the database row, but I still cannot login.
Reconfiguring with sudo dpkg-reconfigure mysql-server-5.7 doesn't do anything, I get this:
Checking if update is needed.
This installation of MySQL is already upgraded to 5.7.12, use --force if you still need to run mysql_upgrade
$ sudo dpkg-reconfigure --force mysql-server-5.7
Checking if update is needed.
This installation of MySQL is already upgraded to 5.7.12, use --force if you still need to run mysql_upgrade
Any ideas?
MySQL 5.7 generates a random root password by itself on installation.
This was a new change in MySQL 5.7.4, and described in the release notes: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-4.html
The installation process creates only a single root account,
'root'#'localhost', automatically generates a random password for this
account, and marks the password expired. The MySQL administrator must
connect as root using the random password and use SET PASSWORD to
select a new password. (The random password is found in the
.mysql_secret file in the home directory of the effective user running
the script.)
I never find the .mysql_secret file, but the random password is also output in the MySQL error log (e.g. /var/log/mysqld.log on Linux). The notice looks like this:
2016-07-11T15:59:54.922316Z 1 [Note] A temporary password is generated for root#localhost: f14_W1lN7FfP
You could either reinstall everything, which i did. I had initially installed using macos package installer. That didn't get me anywhere.
So uninstalled everything, then upgraded brew, and installed via brew. Running the mysql shell proved a messy affair. Ultimately what worked was mysql -u root -p.
I was running it on localhost, so turns out root password wasn't required. Weirdly, mysql -u root -p <password> threw the "access denied" message.
Proper re-installing helped. Removed everything associated (this instruction, but it is important to specify the version of mysql, e.g. apt-get --yes purge mysql-server-5.7 mysql-client-5.7, and I also deleted mysql-common and all dependencies to be sure).
Then installed again (apt-get install mysql-server mysql-client) and when it asked for a password, this time, I gave it one. It works now.

Joomla installation prevention with a mysql warning

I seem to keep encountering an installation issue for installing Joomla on Linux. Although without Joomla I can still independently create/modify sql queries accessing mariadb with mysql -u root -p then starting lampp with sudo /opt/lampp/lampp start and website building as soon as I xdg-open /opt/lampp/htdocs, I am still unable to figure out how to by pass the Warning I keep getting when I try to install Joomla by creating that Admin account installation process.
The warning message I keep getting is: `The installer was not able to connect to the MySQL. Please make sure MySQL is running and introduce a valid password to connect to the MySQL server.
I was assuming the MYSQL was automatically running since I am able to create sql fields and input them from mariadb... and also the fact that when I run: mysqladmin -u root -p status because I still see Uptime, but I do not think that is the case.. so I am not really sure...

Installing xampp but phpmyadmin doesn't connect

So I installed xampp on my Linux machine running Ubuntu 14.04LTS. Now all of a sudden turns out when I try to connect to phpmyadmin it refuses to connect. I have already installed mysql separately as well but it doesn't seem to work. Any workaround for this?
The error that I get is :
MySQL said:
Cannot connect: invalid settings.
Connection for controluser as defined in your configuration failed.
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
Any reason why this happens and solution to it?
Go to http://localhost/security/ and then click on the link http://localhost/security/xamppsecurity.php.
After that change password for superuser to 'root'.
After that open your http://localhost/phpmyadmin/
As per the comment by RiggsFolly I was running two instances of MySQL
So both mysql servers do end up messing with phpmyadmin and this is how you shutdown the external mysql server while using xampp's inbuilt mysql server to connect successfully using phpmyadmin:
Use whichmysql to find the utility that is running
Navigate to the directory where the external MySQL service is running:
$ cd /usr/bin
$ mysqladmin shutdown
This shuts down the MySQL service running if at all it is running.
$ sudo service mysql stop
This helps as well if at all it will tell you the status of the service if it is already shut down.
Now we need to stop the Xampp mysql server so we navigate to /lampp/bin and again execute the same command to shut mysql server down.
$ cd /opt/lampp/bin
$ mysqladmin shutdown
Simply restart xampp and you should be good to go.
$ sudo /opt/lampp/lampp restart
I just fell into the same error. The solution I used was, stopping all the servers of xampp, exiting the program. Starting and stoping mysql then starting xampp again
Initial procedure before starting xampp:
sudo service mysql stop
sudo /etc/init.d/apache2 stop
If it bring the error as stated in this question, then follow the procedure below.
That is:
sudo /opt/lampp/lampp stop
sudo service mysql start
sudo service mysql stop
sudo /opt/lampp/lampp start