Install MySQL under Linux (2) and solve common problems

Source: Internet
Author: User

The previous article on the basic installation, this is counted as the advanced bar

Link Linux install MySQL (1)

1. Prepare the MySQL RPM installation package

2. Unzip and enter Usr/local/mysql

3. Execute useradd MySQL First (create a MySQL user who manages the database)

In fact this MySQL user is already in the MySQL user group, and by default, when the user is added, a group with the same name is generated

can view

4. Create a Data folder in the current MySQL directory to hold the

5. Change the group of files so that the MySQL group is easy to manage the database

Chgrp-r MySQL.

Change the owner of the Data folder (so that it is convenient for future operations and does not require root access)

Chown-r MySQL Data

6. Next go to Bin directory

Execution./mysqld--initialize--user=mysql

Note Save the temporary password that is generated at this time

7../mysqld_safe--user=mysql &

NETSTAT-ANP |grep 3306

See there are 3306 ready to sign in

8.ln-s/usr/local/mysql/data/mysql.sock/tmp/mysql.sock Resolve Error 2002 (HY000): Can ' t connect to local MySQL server through Socket '/tmp/mysql.sock ' (2)

You can also directly modify the socket path in the configuration file

(Can find/-name Mysql.sock first)

9.

./mysql-u Root-p
Alter user "root" @ "localhost" identified by "123";

Sign in and change your password

10. Configure the environment variables. Configure the MySQL service

Vim/etc/profile

After saving remember Source/etc/profile refresh under

Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysql

Service MySQL start successful boot ok

11. Testing

Leave the bin directory and re-mysql-u Root-p

It's OK to log in.

12. Frequently Asked Questions

① if the database times are initialized

Can ' t create directory ' xxxx ' (OS errno 2-no such file or directory)

There's a problem with the path to the configuration file, mostly.

②mysqld.pid Ended

If the initialization occurs, the first cat under the log file, if the error (no this directory, etc.), most of your configuration file log path is not with the PID path, that is, the two files are not in the same directory

If the configuration file is correct, then find under Mysqld.pid, if found to create a soft connection to your original path or change this path to the value of Pid-file in your configuration file

If you still have a problem, delete all the files in the data directory, reinitialize the database, and try again. Juvenile

Install MySQL under Linux (2) and solve common problems

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.