Install MySQL Community edition on Centos

Source: Internet
Author: User

Install MySQL Community edition on Centos

Bytes

2. There is no./configure & make in the mysql installation package. You need to follow the instructions. Here, we can see INSTALL-BINARY in the installation package.

There is a section

Shell> groupadd mysql

Shell> useradd-r-g mysql-s/bin/false mysql

Shell> cd/usr/local

Shell> tar zxvf/path/to/mysql-VERSION-OS.tar.gz #Change the path to the location and name of the downloaded installation package.

Shell> ln-s full-path-to-mysql-VERSION-OS mysql #Same as above. Fill in the actual extracted path name

Shell> cd mysql

Shell> mkdir mysql-files

Shell> chmod 770 mysql-files

Shell> chown-R mysql.

Shell> chgrp-R mysql.

Shell> bin/mysql_install_db -- user = mysql #Before MySQL 5.7.6

Shell> bin/mysqld -- initialize -- user = mysql #When initializing MySQL 5.7.6 and up, you must carefully check the screen. At last, there is probably A line 2015-12-24T09: 05: 03.283677Z 1 [Note] A temporary password is generated for root @ localhost:KklNBwkei1.t# Note: This is the temporary root password.

Shell> bin/mysql_ssl_rsa_setup # MySQL 5.7.6 and up

Shell> chown-R root.

Shell> chown-R mysql data mysql-files #An error is reported when this statement is executed. I just want to remove the data.

Shell> bin/mysqld_safe -- user = mysql &

# Next command is optional

Shell> cp support-files/mysql. server/etc/init. d/mysql. server #Note that the cp name is mysql. server instead of mysqld. Therefore, you must use service mysql when starting the service. server start. If you want to use mysqld, write the last sentence cp support-files/mysql. server/etc/init. d/mysqld.

The operation is simple. However, I made a mistake, copied the wrong line, and initialized it before I found out. You have to go to rm to drop the mysql directory under the/var/lib directory and start again.

Start servicemysqld start (as mentioned in the previous step, some may be service MySQL. server start) and start logging on.

For convenience, a link file ln-s/usr/local/mysql/bin/MySQL is created in the bin directory, you can also add this PATH to the environment variable, for example, PATH = $ PATH:/usr/local/MySQL/bin.

The following error is always reported during subsequent Logon:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql. sock' (2)

It seems that the socket file cannot be found. Check the file. If the file is damaged, restart the service. This indicates that the configuration file similar to the listening port will appear after the service is started.

Then I tried mysql-uroop-p -- socket =/var/lib/mysql. sock and entered the password recorded during initialization.

Logon successful

Therefore, ln-s/var/lib/mysql. sock/tmp/mysql. sock

Then we can get everything done.

The last step is to change the root password.

Set password for 'root' @ 'localhost' = password ('wjz ');

Note that the above operations are completed under the root account. When we exit the normal account, we may find that ERROR 2002 (HY000) is still reported when executing the MySQL command ): can't connect to local MySQL server through socket '/tmp/mysql. sock '(2)
This may be a permission issue. Check the MySQL. sock file in the/tmp directory and the/var/lib/mysql directory, and change the permission to solve the problem.

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.