Install MySQL under Linux

Source: Internet
Author: User

1. Download the MySQL installation package:

: Http://dev.mysql.com/downloads/mysql/5.6.html#downloads

Download version: I choose here 5.6.33, General edition, Linux under 64-bit

You can also copy the 64-bit directly through the command

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz--no-check-  -XVF mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
2, uninstall the old version of MySQL

Find and delete mysql-related files

find / -name mysqlrm -rf 上边查找到的路径,多个路径用空格隔开#或者下边一条命令即可find / -name mysql|xargs rm -rf

3, in the installation package storage directory to execute the command decompression file:
tar -xvf mysql-5.6.31-linux-glibc2.5-x86_64.tar.gz

4. Rename the extracted files
mv mysql-5.6.31-linux-glibc2.5-x86_64/ mysql

5. Add MySQL user group and MySQL user

Check for MySQL user groups and MySQL users first

groups mysql

If none, then add;

groupadd mysqluseradd -r -g mysql mysql

If there is, then skip;


6. Go to MySQL directory to change permissions
cd mysql/chown -R mysql:mysql ./

7. Execute the installation script
--user=mysql

After installation, modify the current directory owner as the root user, modify the data directory owner to MySQL

root:root ./chown -R mysql:mysql data

Paste_image.png8, change MySQL password

The log in the previous installation script execution output tells us how to change the password.


But if you execute these two commands directly, you'll get an error.


Because this is not the start of MySQL, this is a pit. The startup method is as follows:

./support-files/mysql.server start

If MySQL starts an error, it is possible that the MySQL process already exists and can be killed

ps aux|grep mysqlkill -9 上边的进程号#或者下边一条命令即可杀掉所有MySQL进程ps aux|grep mysql|awk ‘{print $2}‘|xargs kill -9

Kill and then start. Or there are other MySQL files that interfere with MySQL startup, so before installing to remove the other MySQL directory, if it does not start, then delete all the MySQL directory, reinstall

After MySQL starts, execute the following command to change the password:

./bin/mysqladmin -u root -h localhost.localdomain password ‘123456‘

Log in to MySQL after you change your password

./bin/mysql -h127.0.0.1 -uroot -p123456

9. Modify the configurationHowever, if the./bin/mysql-uroot-p123456 login, the system will error: can ' t connect to local MySQL server through socket '/tmp/mysql.sock ' (2) "; Posts: 78850658 authentication method:
./bin/mysql-uroot-p-s/var/lib/mysql/mysqld.sock

If you can connect to MySQL by executing the above command, use the workaround below
Workaround:
Ln-s/var/lib/mysql/mysqld.sock/tmp/mysql.sock

ls/tmp/

Also, change the etc/my.cnf file's bind-address = 127.0.0.1 to bind-address = 0.0.0.0, and if the configuration file does not have this configuration, manually add

This step is optional:

Password for other users can also be changed to root after login

update mysql.user set password=password(‘root‘) where user=‘root‘;flush privileges;

10. Turn off the firewallService Iptables Stop 11. Increase Remote Login Permissions

The previous step allows you to log on locally, but remote login will error


In order to solve this problem, we need to log on to MySQL locally and execute the following command
grant all privileges on *.* to [email protected]‘%‘ identified by ‘123456‘;flush privileges;

Telnet after execution

Forwarded from Link: 71171614

Install MySQL under Linux

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.