Install MySQL under Linux

Source: Internet
Author: User
Tags documentation symlink

1.1. detect if MySQL is already installed

Rpm-qa | grep MySQL

If it is already installed, uninstall it, such as:

RPM-E--nodeps mysql-libs-5.1.71-1.el6.x86_64

1.2. installing MySQL

1, Mkdir/usr/local/src/mysql

2, Cd/usr/local/src/mysql

3, TAR-XVF Mysql-5.6.22-1.el6.i686.rpm-bundle.tar (decompression)

4. Installing the server
RPM-IVH mysql-server-5.6.22-1.el6.i686.rpm
Error:

Installation dependent: yum-y Install libaio.so.1 libgcc_s.so.1 libstdc++.so.6

Need to upgrade libstdc++-4.4.7-4.el6.x86_64
Yum Update libstdc++-4.4.7-4.el6.x86_64

5, the installation:

6. Install Client

Installation dependent: yum-y Install libncurses.so.5 libtinfo.so.5

7, Query mysq service running status

The service is not started.

8. Start the MySQL service
Service MySQL Start

9. Log in to MySQL using the root account
Tips:

There is a prompt when installing MySQL server:

1, note: This password is not secure, all need to modify the initial password.

2. Login MySQL account with password: mysql-uroot-p

3. Change the root password: SET PASSWORD = PASSWORD (' 123456 ');

2.3 start the MySQL service automatically when the system starts

Attention:

CENTOS7 began to change the way the/ETC/INIT.D startup scripts of previous versions of the system services were changed, and all the management of the services in CENTOS7 was centralized in Systemctl.
Systemctl is a collection of system Management daemons, tools, and libraries that replace previous system V, service, and Chkconfig commands.

Create a configuration file to start MySQL
[Email protected] ~]# Touch/usr/lib/systemd/system/mysqld.service
[Email protected] ~]# Cd/usr/lib/systemd/system

Edit the Mysqld.service file to add the following:
[Email protected] system]# VI mysqld.service
[Unit]
Description=mysql Server
Documentation=man:mysqld (8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target

[Install]
Wantedby=multi-user.target

[Service]
User=mysql
Group=mysql
Execstart=/opt/mysql-5.7.18/bin/mysqld--defaults-file=/etc/my.cnf
Limitnofile = 5000
Save exit

Remark: Execstart=/opt/mysql-5.7.18/bin/mysqld (please change to the path of MySQL program here)
Find the mysqld path, for example:
[email protected] system]# which mysqld
/opt/mysql-5.7.18/bin/mysqld

Start the mysql5.7 by Systemctl mode:
[Email protected] system]# systemctl start mysqld

Check MySQL run Status:
[Email protected] system]# mysql-p
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 6
Server Version:5.7.18-log MySQL Community Server (GPL)

To turn off the firewall:
[Email protected] system]# Systemctl stop Firewalld.service
[Email protected] system]# systemctl disable Firewalld.service
Removed Symlink/etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed Symlink/etc/systemd/system/dbus-org.fedoraproject.firewalld1.service.

To set up MySQL boot:
[Email protected] system]# Systemctl enable mysqld
Created symlink From/etc/systemd/system/multi-user.target.wants/mysqld.service to/usr/lib/systemd/system/ Mysqld.service.
[Email protected] system]# Systemctl list-unit-files | grep mysqld
Mysqld.service enabled

To cancel the MySQL boot from:
[Email protected] system]# systemctl disable mysqld
Removed Symlink/etc/systemd/system/multi-user.target.wants/mysqld.service.
[Email protected] system]# Systemctl list-unit-files | grep mysqld
Mysqld.service disabled

Install MySQL under Linux

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.