So far, they have been working well for me. You can do your own research and/or try out these settings. I added the following lines after spending some time researching some basic MySQL optimizations. The default content is: $ cd /opt/homebrew/etc The MySQL installation creates a my.cnf configuration file at /opt/homebrew/etc. This section is totally optional, but I wanted to make some very basic optimizations before I started creating databases. The mydbctl script verifies that the service process is running (or not) before reporting success. I have seen instances where the brew services restart action said that it was successful, but the MySQL service did not actually start up. You can try both and decide what works for you. This shell script is completely compatible with the brew services actions. There is additional error checking, including actually waiting for the MySQL service to start or stop. Ps -axo user,pid,start,etime,time,nice,vsz,rss,command |\ if ! pgrep -q mysqld thenĮcho "mysql is already stopped, so just start it up. Launchctl unload ~/Library/LaunchAgents/ > /dev/ null 2>& 1 Launchctl load ~/Library/LaunchAgents/ > /dev/ null 2>& 1Įcho "mysql is already stopped. "Ĭp /opt/homebrew/opt/mysql/ ~/Library/LaunchAgents/Įrror_exit " copy failed. If thenĮrror_exit "Cannot start mysql - is missing. Until pgrep -q $process || ]ĭo echo "waiting for $process to start $count. Sleep 1 # give process time to die for configuration file errors. Until ! pgrep -q $process || ]ĭo echo "waiting for $process to stop $count. # Usage if ]Įrror_exit "Usage: mydbctl start|stop|restart|status" else Create an executable file named mydbctl in your user bin directory and add the following content: #!/bin/zsh # Usage: mydbctl start|stop|restart|status While this shell script supports the same actions as the brew services command, it actually verifies that the service stopped and/or started successfully. USER PID STARTED ELAPSED TIME NI VSZ RSS COMMAND Make sure that you have stopped MySQL with the above brew services command before trying to use mydbctl. I mention that I wrote a shell script, mydbctl, to control and monitor my MySQL service. After doing so, you will have to use your root password to connect to MySQL: $ mysql -u rootĮRROR 1045 ( 28000): Access denied for user 'localhost' (using password: NO)Ĭopy Code Using a Shell Script to Control the MySQL Service After creating your root password, answer Y to all the remaining questions. While this may be fine for a local development environment, you can run mysql_secure_installation to create a root password and to secure your MySQL installation. The default Homebrew MySQL installation does not require a root password. => Successfully stopped `mysql` (label: )Īs of this writing, Homebrew installs MySQL version 8.1. Type '\c' to clear the current input statement. Other names may be trademarks of their respective Oracle is a registered trademark of Oracle Corporation and/or itsĪffiliates. Commands end with or \g.Ĭopyright (c) 2000, 2023, Oracle and/or its affiliates. => Successfully started `mysql` (label: ) The following shows how to install MySQL 8.x and how to start up the MySQL service, using the brew services command. Installing MySQL 8.x with the brew command I will again use Homebrew to install MySQL version 8.x. Please add a comment if something is not working or is not clear. Be sure to correctly set your PATH for the processor version that you are using. Homebrew uses a different path, /opt/homebrew/bin, instead of /usr/local/bin, which is used for Intel processors. I updated this post for macOS Sonoma and Apple Silicon processors.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |