10bet网址
MySQL 5.6 Reference Manual
Related Documentation Download this Manual Excerpts from this Manual

2.10.2.1 Troubleshooting Problems Starting the MySQL Server

This section provides troubleshooting suggestions for problems starting the server. For additional suggestions for Windows systems, seeSection 2.3.5, “Troubleshooting a Microsoft Windows MySQL Server Installation”.

If you have problems starting the server, here are some things to try:

  • Check theerror logto see why the server does not start. Log files are located in thedata directory(typicallyC:\Program Files\MySQL\MySQL Server 5.6\dataon Windows,/usr/local/mysql/datafor a Unix/Linux binary distribution, and/usr/local/varfor a Unix/Linux source distribution). Look in the data directory for files with names of the formhost_name.errandhost_name.log, wherehost_nameis the name of your server host. Then examine the last few lines of these files. Usetailto display them:

    shell> tailhost_name.err shell> tailhost_name.log
  • Specify any special options needed by the storage engines you are using. You can create amy.cnffile and specify startup options for the engines that you plan to use. If you are going to use storage engines that support transactional tables (InnoDB,NDB), be sure that you have them configured the way you want before starting the server. If you are usingInnoDBtables, seeSection 14.8, “InnoDB Configuration”for guidelines andSection 14.14, “InnoDB Startup Options and System Variables”for option syntax.

    Although storage engines use default values for options that you omit, Oracle recommends that you review the available options and specify explicit values for any options whose defaults are not appropriate for your installation.

  • Make sure that the server knows where to find thedata directory. Themysqldserver uses this directory as its current directory. This is where it expects to find databases and where it expects to write log files. The server also writes the pid (process ID) file in the data directory.

    The default data directory location is hardcoded when the server is compiled. To determine what the default path settings are, invokemysqldwith the--verboseand--help选项。如果data directory is located somewhere else on your system, specify that location with the--datadiroption tomysqldormysqld_safe, on the command line or in an option file. Otherwise, the server does not work properly. As an alternative to the--datadiroption, you can specifymysqldthe location of the base directory under which MySQL is installed with the--basedir, andmysqldlooks for thedatadirectory there.

    To check the effect of specifying path options, invokemysqldwith those options followed by the--verboseand--help选项。For example, if you change location to the directory wheremysqldis installed and then run the following command, it shows the effect of starting the server with a base directory of/usr/local:

    shell> ./mysqld --basedir=/usr/local --verbose --help

    You can specify other options such as--datadiras well, but--verboseand--helpmust be the last options.

    Once you determine the path settings you want, start the server without--verboseand--help.

    Ifmysqldis currently running, you can find out what path settings it is using by executing this command:

    shell> mysqladmin variables

    Or:

    shell> mysqladmin -hhost_namevariables

    host_nameis the name of the MySQL server host.

  • Make sure that the server can access thedata directory. The ownership and permissions of the data directory and its contents must allow the server to read and modify them.

    If you getErrcode 13(which meansPermission denied) when startingmysqld, this means that the privileges of the data directory or its contents do not permit server access. In this case, you change the permissions for the involved files and directories so that the server has the right to use them. You can also start the server asroot, but this raises security issues and should be avoided.

    Change location to the data directory and check the ownership of the data directory and its contents to make sure the server has access. For example, if the data directory is/usr/local/mysql/var, use this command:

    shell> ls -la /usr/local/mysql/var

    如果data directory or its files or subdirectories are not owned by the login account that you use for running the server, change their ownership to that account. If the account is namedmysql, use these commands:

    shell> chown -R mysql /usr/local/mysql/var shell> chgrp -R mysql /usr/local/mysql/var

    Even with correct ownership, MySQL might fail to start up if there is other security software running on your system that manages application access to various parts of the file system. In this case, reconfigure that software to enablemysqldto access the directories it uses during normal operation.

  • Verify that the network interfaces the server wants to use are available.

    If either of the following errors occur, it means that some other program (perhaps anothermysqldserver) is using the TCP/IP port or Unix socket file thatmysqldis trying to use:

    Can't start server: Bind on TCP/IP port: Address already in use Can't start server: Bind on unix socket...

    Usepsto determine whether you have anothermysqldserver running. If so, shut down the server before startingmysqldagain. (If another server is running, and you really want to run multiple servers, you can find information about how to do so inSection 5.7, “Running Multiple MySQL Instances on One Machine”.)

    If no other server is running, execute the commandtelnetyour_host_nametcp_ip_port_number. (The default MySQL port number is 3306.) Then press Enter a couple of times. If you do not get an error message liketelnet: Unable to connect to remote host: Connection refused, some other program is using the TCP/IP port thatmysqldis trying to use. Track down what program this is and disable it, or tellmysqldto listen to a different port with the--portoption. In this case, specify the same non-default port number for client programs when connecting to the server using TCP/IP.

    Another reason the port might be inaccessible is that you have a firewall running that blocks connections to it. If so, modify the firewall settings to permit access to the port.

    如果server starts but you cannot connect to it, make sure that you have an entry in/etc/hoststhat looks like this:

    127.0.0.1 localhost
  • If you cannot getmysqldto start, try to make a trace file to find the problem by using the--debugoption. SeeSection 5.8.3, “The DBUG Package”.