Troubleshooting of mysql database startup exceptions in ubuntu _ MySQL

Source: Internet
Author: User
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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.