Screenshots of steps for installing MySql in Linux: linuxmysql

Source: Internet
Author: User

Detailed steps for installing MySql in Linux: linuxmysql

The following is a record in my work. We will introduce the installation process and screenshot of installing MySql using officially compiled binary files in linux. This installation method is fast and the installation steps are simple!

If you want to install MySql quickly, follow these steps :)!

1. Download the binary installation package for mysql linux:

Address: http://dev.mysql.com/downloads/mysql/

Here I rename the installation package to: tingyun-mysql-5.6.22.tar.gz

Note: You can choose not to rename the file as needed.

2. Unzip the installation package:

Decompress the installation package at the desired location: run the following command:

<span style="font-size: 16px; font-family: "Microsoft YaHei""> cd /opt tar –xPf tingyun-mysql-5.6.22.tar.gz</span>

Screenshots are as follows:

3. Create the mysql installation directory and modify the directory permissions:

Run the following command:

Create a mysql Directory: mkdir mysql

Open the mysql Directory: cd mysql

Create data directory: mkdir data

Note: Because the mysql service process mysqld will access the data directory during running, you need to create the data directory.

Run the following command in the mysql directory to set the directory owner to a mysql user:

<span style="font-size: 16px; font-family: "Microsoft YaHei"">chown mysql:mysql /opt/mysql –R</span>

Screenshots are as follows:

5. Install mysql

Run the installation command mysql_install_db In the mysql directory:

<span style="font-size: 16px; font-family: "Microsoft YaHei"">./scripts/mysql_install_db --user=mysql –datadir=/opt/mysql/data</span>

Screenshots are as follows:

6. Start mysql

Go to the init. d directory and run the following command:

<span style="font-size: 16px; font-family: "Microsoft YaHei"">cd /etc/init.d/mysqld restart</span>

If you do not want to restart the instance, you can manually start the instance and run the following command:

<span style="font-size: 16px; font-family: "Microsoft YaHei"">service mysqld start</span>

You can also directly execute the following command in the mysql directory:

<span style="font-size: 16px; font-family: "Microsoft YaHei"">/etc/init.d/mysqld restart</span>

Screenshots are as follows:

7. Create a soft link for mysql

Run the following command:

<span style="font-size: 16px; font-family: "Microsoft YaHei"">ln –s /opt/mysql/bin/mysql /user/bin</span>

Screenshots are as follows:

8. Modify mysql Configuration

Run the following command to edit the file:

<span style="font-size: 16px; font-family: "Microsoft YaHei"">vim .bash_profile</span>

Description: configure the directory for using./mysql (for example, using./mysql in the bin directory)

(1) write at the bottom of the bash_profile File

<Span style = "font-size: 16px; font-family:" Microsoft YaHei ""> export PATH = $ PATH: /usr/local/mysql/bin (your installation bin directory) </span>

Run the wq command to save and exit.

(2) execute the source command to make the system configuration take effect:

<span style="font-size: 16px; font-family: "Microsoft YaHei"">source /.bash_profile</span>

Screenshots are as follows:

9. Security Configuration Wizard

After installing Mysql, You need to configure the security of mysql according to the Security Configuration:

Run the following command to configure the security of the mysql root User:

<span style="font-size: 16px; font-family: "Microsoft YaHei"">mysql_secure_installation</span>

Select "Y" for the new password, and enter the new password twice (the second is used as the confirmation password ).

Delete anonymous users and select "Y"

Screenshots are as follows:

You can also set a password for the root user as follows:

Run the following command:

<span style="font-size: 16px; font-family: "Microsoft YaHei"">mysql –uroot –pnbs2o13</span>

Screenshots are as follows:

View the content in the mysql installation directory

Screenshots are as follows:

10. Test mysql after installation:

(1) Check whether mysql has been started:

You can use either of the following three commands:

<span style="font-size: 16px; font-family: "Microsoft YaHei"">netstat -tl | grep mysqlps -aux | grep mysqldnetstat -lntup|grep 3306</span>

The mysql-related process is printed on the screen and the following similar content is displayed:

<span style="font-size: 16px; font-family: "Microsoft YaHei"">tcp 0 0 *:mysql *:* LISTEN</span>

Mysql has been started successfully!

(2) to use mysql, run the following command to access mysql:

<span style="font-size: 16px; font-family: "Microsoft YaHei"">mysql -u root -p</span>

(3) view the version:

<span style="font-size: 16px; font-family: "Microsoft YaHei"">select version();</span>

The above section describes how to install MySql in Linux. I hope it will be helpful to you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.