Welcome to part 3 of the MAMP tutorial. In this post we will go over setting up phpMyAdmin on your Mac’s localhost. Part 2 walks you through installing mysql on your localhost read. Part 1 shows you how to setup up Apache on your Mac.
Welcome to part 2 of the MAMP tutorial. In this part we will go over setting up Mysql on your Mac’s localhost. Part 1 goes over everything you need to do to setup PHP on a Mac
I’ve been setting up a LEMP server, Nginx Mysql PHP, on Ubuntu and lost my root mysql password. Here’s what I did to reset the password in Terminal.
After logging into my server via SSH on Terminal I ran the following lines in Terminal.
# /etc/init.d/mysql stop # mysqld_safe --skip-grant-tables & $ mysql -u root mysql> use mysql; mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root'; mysql> flush privileges; mysql> quit # /etc/init.d/mysql stop # /etc/init.d/mysql start $ mysql -u root -p
I found this solution in an answer by Benjamin Manns to a StackOverflow question here.
Recently our servers went down. The error we were getting was “Too many connections”. This meant that we needed to increase the limit on the number of available connections within our mysql config file. The setting is called
Before you go upping the number of max user connections there are two things to consider.
1. Is your code opening and closing the connections efficiently?
According to the mysql “using mysql_close() isn’t usually necessary, as non-persistent open links are automatically closed at the end of the script’s execution.” However, there are rare occasions where the connections do not close properly, so it is always a good rule of thumb to include mysql_close() at the end of your scripts.
Another mistake that can occur is that you may be unintentionally opening a new connection for each query, rather than opening one connection and then closing it once all your queries are completed. This will definitely increase the number of user connections.
Also, using persistent connections are generally frowned upon these days. For php using mysql_connect has actually proven to be more efficient.
2. Do you have enough memory (RAM) available to handle your increased connections.
Once you know your code is clean and you are still running out of available user connections the next step will be to increase your number of max_connections on your mysql config file.
It is important to calculate your available memory before upping your connection limit however, other wise you will encounter this error:
Connect Error (1135) Can't create a new thread (errno 12); if you are not out of available memory, you can consult the manual for a possible OS-dependent bug
This error is simply telling you that you are using too much memory. To avoid this error when upping your connection number use the following formula to calculate your number of available connections.
Key_buffer_size + ((read_buffer_size + sort_buffer_size)*max_connections) = memory needed
If you know your server’s ram, calculating the number of max_connections is straight forward.
I hope this helps you if you are encountering this problem
Note: Your current settings for Key_buffer_size, read_buffer_size, sort_buffer_size and max_connections can all be found in your mysql config file.