Troubleshooting of mysql database startup exceptions in ubuntu
BitsCN.com
Run the following command to install mysql in ubuntu 12.04:
sudo apt-get install mysql-server mysql-client
Install
After the installation, it starts normally, but finds that the mysqld service only listens to the 127.0.0.1 IP address of port 3306,
sudo netstat -ntlptcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 5459/mysqld
So I checked it online and found that
bind-address = 127.0.0.1
This indicates that it listens to requests from 127.0.0.1, so I stopped the mysql service and modified the configuration file.
Bind-address = 0.0.0.0
This means that mysql will listen to requests from any IP address (of course, the port number must be 3306 ).
When I changed the file to a read-only file, I changed the file permission to 777.
sudo chmod 777 my.cnf
Then, I restarted the mysql service and found that the service could not be restarted, an error was reported, and no logs were found.
However, I had to uninstall mysql and reinstall it.
sudo apt-get remove mysql-server mysql-client
I found that mysql cannot be fully uninstalled in this way. by querying github, I learned that the purge parameter must be added to completely uninstall all files including configuration files, and mysql-common must be added.
sudo apt-get install remove --purge mysql-server mysql-client mysql-common
After the reinstallation, the problem persists: mysql cannot be restarted after the configuration file my. cnf is changed.
After investigation by multiple parties, I found that this is because I changed my. cnf permission, so that the file can be read and modified by any user, which is not allowed by mysql. So after I changed my. cnf,
Change the permission to 644 by default and restart mysql again.
At this time, I used sudo netstat-nltp to check the listening status of port 3306 and found that it has changed:
Sudo netstat-ntlptcp 0 0 0.0.0.0: 3306 0.0.0.0: * LISTEN 5459/mysqld
This means that the mysqld service has started to listen for requests from external IP addresses. However, this does not mean that requests from external IP addresses have the permission to operate mysql databases and must be granted with the following permissions:
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;FLUSH PRIVILEGES;
In this case, you can access the database from an external IP address. BitsCN.com