In this section, you will find a lot of useful MySQL administration tutorials including MySQL server start-up and shutdown, MySQL server security, MySQL database maintenance, backup and replication. Before proceeding with the installation, be sure to stop all running MySQL server instances by using either the MySQL Manager Application (on macOS Server), the preference pane, or mysqladmin shutdown on the command line.
To interact with MySQL by instead of using the command line, phpMyAdmin comes to the rescue, to get it running as part of your local development set up on OS X, a couple of steps need to be done. phpMyAdmin is a browser application that interacts with the underlying mysql data.
These steps will work on Mac OS X 10.9 Mavericks, OSX 10.8 Mountain Lion, 10.7 and 10.6 Snow Leopard.
Preparing for phpMyAdmin
Download the latest version now at version 4.something phpMyAdmin, the english.zip should be sufficient, after the file is downloaded unzip it and move it to your personal web sharing folder, this will either be “/Users/username/Sites” directory or other web root folder such as “/Library/WebServer/Documents/“.
Rename the folder from “phpMyAdmin-4.0.0-english” to “phpmyadmin“.
The rest of the tutorial assumes that you have already mysql set up with a mysql root user and password enabled if not then please follow that process first.
The login address for phpMyAdmin is going to be http://localhost/~username/phpmyadmin/ or http://localhost/phpmyadmin/ depending on your web root directory, but before this will work correctly a few steps need to be done namely addressing the MySQL socket error and configuration file set up:
a) Launch /Applications/Utilities/Terminal to fix the mysql 2002 socket error by entering the following commands:
Basically this is making an alias to where phpmyadmin thinks the mysql.sock is and where it actually is.
Mysqladmin For Macbook
b) In the phpmyadmin folder in your web root make a new directory named “config”.
c) Give Others “write“permissions to the “/phpmyadmin/config” folder either through Get Info or a ‘chmod o+w‘ in Terminal.
Installing phpMyAdmin
Older Safari browser currently has issues with the installation, blank screens?? Upgrade to Safari 6 or use either Chrome or Firefox.
Now we are ready to run the set up in the browser by going to:
http://localhost/~username/phpmyadmin/setup/
or
http://localhost/phpmyadmin/setup/
The new server to be configured is the localhost, click new server and then the only other configurations are the local mysql root user and the password in the Authentication tab.
Add in the username, by default “root” is assumed, add in the mysql root password (this is the password for mysql not for the OSX admin account) , click on save and you are returned to the previous screen.
Make sure you click on save, then a config.inc.php is now in the /config directory, move this file to the root level of /phpmyadmin and then remove the now empty /config directory.
Now going to http://localhost/~username/phpmyadmin/ or http://localhost/phpmyadmin/will now allow you to interact with your MySQL databases.
Mcrypt missing extension – If your applications don’t require the mcrypt extension there is no need to worry about it missing as reported in phpMyAdmin, if you do need to install it follow the guide here on mcrypt extension in Mavericks.
Upgrading phpMyAdmin is an easy task just grab the latest version from the phpmyadmin website and replace your older phpMyAdmin directory in your web shared folder apart from the “config.inc.php” file – make sure the config.inc.php is kept and put it back in the new directory.
NOTE: We are in the process of modifying the configuration for many Bitnami stacks. On account of these changes, the file paths and commands stated in this guide may change depending on whether your Bitnami stack uses MySQL or MariaDB. To identify which database server is used in your stack, run the command below:
The output of the command indicates which database server (MySQL or MariaDB) is used by the installation, and will allow you to identify which guides to follow in our documentation for common database-related operations.
Change the MySQL root password
NOTE: When setting a new password, avoid the use of special characters or quotes, as this can sometimes cause issues when accessing the database through shell scripts.
Linux and Mac OS X
You can modify the MySQL password using the following command at the shell prompt. Replace the NEW_PASSWORD placeholder with the actual password you wish to set.
Windows
You can modify the MySQL password using the following command at the shell prompt. Replace the NEW_PASSWORD placeholder with the actual password you wish to set.
Mysqladmin For Mac Os
Reset the MySQL root password
Linux and Mac OS X
If you don’t remember your MySQL root password, you can follow the steps below to reset it to a new value: Bamboo driver for mac.
Create a file in /tmp/mysql-init with the content shown below (replace NEW_PASSWORD with the password you wish to use).
If your stack ships MySQL v8.x, use this content:
If your stack ships MySQL v5.7.x, use this content:
If your stack ships MySQL v5.6.x or earlier, use this content:
TIP: Check the MySQL version with the command installdir/mysql/bin/mysqladmin --version or installdir/mysql/bin/mysqld --version
Stop the MySQL server:
Start MySQL with the following command:
If your stack ships MySQL v8.x, use this command:
If your stack ships an older version of MySQL, use this command:
Restart the MySQL server:
Remove the script:
Windows
If you don’t remember your MySQL root password, you can follow the steps below to reset it to a new value:
Mysqladmin For Macbook Pro
- Stop the MySQL server using the graphic manager tool. Learn how to start or stop the services.
Check the MySQL version:
Create a file named mysql-init.txt with the content shown below depending on your MySQL version (replace NEW_PASSWORD with the password you wish to use):
MySQL 5.7.x or MySQL 8.x:
MySQL 5.6.x or earlier:
Start MySQL server with the following command. Remember to replace PATH with the location in which you have saved the mysql-init.txt file:
If your stack ships MySQL v8.x, use this command:
If your stack ships an older version of MySQL, use this command:
- The --init file option is used by the server for executing the content of the mysql-init.txt file at startup, it will change each root account password.
- The --defaults-file option is specified since you have installed MySQL using the Bitnami installer.
- The --console option (optional) has been added in order to show the server output at the console window rather than in the log file.
After some minutes, hit Ctrl-C to force the shutdown.
Restart the MySQL server from the graphic manager tool.
After the server has restarted successfully, delete the mysql-init.txt file.