Day1-mysql Installation Method Introduction

Source: Internet
Author: User
Tags mysql client mysql commands

Window version

1. Download

1 MySQL Community Server 5.7.162  3 http://dev.mysql.com/downloads/mysql/

2. Decompression

If you want MySQL to be installed in the specified directory, then move the extracted folder to the specified directory, such as: C:\mysql-5.7.16-winx64

3. Initialization

After MySQL extracted the bin directory there is a lot of executable files, execute the following command to initialize the data:

1 cd c:\mysql-5.7.16-winx64\bin2  3 mysqld--initialize-insecure

4. Start the MySQL service

Execute the command to start the MySQL service

1 # go to the executable file directory 2 cd c:\mysql-5.7.16-winx64\bin3  4#  start MySQL service 5 mysqld

5. Start the MySQL client and connect to the MySQL service

The default password is not set to the root account due to the "mysqld--initialize-insecure" command used during initialization

1 # go to the executable file directory 2 cd c:\mysql-5.7.16-winx64\bin3  4#  connection to MySQL server 5 mysql-u root-p6  7#  prompt Please enter your password and go directly to

Enter the entry to see that the installation was successful:

To this end, the MySQL server has been successfully installed and the client is ready to connect, and in the future to operate MySQL, it is only necessary to repeat the 4, 5 steps. However, in the 4, 5 steps of repeated access to the executable directory is cumbersome, if you want to be easy to operate later, you can do the following operations.

A. Adding environment variables

Add the MySQL executable to the environment variable to execute the command

"Right-click Computer"-"Properties"-"Advanced system Settings"-"Advanced"-"Environment variable"-"in the second content box to find the variable named path of a row, double-click"- "the MySQL Bin directory path appended to the variable value, with; such as: C:\Program Files (x86) \parallels\parallels tools\applications; %systemroot%\system32;%systemroot%;%systemroot%\system32\wbem;%systemroot%\system32\windowspowershell\v1.0\; C:\Python27; C:\Python35; C:\mysql-5.7.16-winx64\bin

This way, when you start the service and connect later, you only need to:

1 # start the MySQL service, enter in the terminal 2 mysqld 3  4 # connect the MySQL service to the terminal input: 5 mysql-u root-p

B. Making a MySQL service into a Windows service

The previous step solves some problems, but is not exhaustive, because the current terminal will be stuck while executing "MYSQD" to start the MySQL server, then do the setup to resolve the problem:

1 # To make a Windows service for MySQL, execute this command at the terminal: 2 " C:\mysql-5.7.16-winx64\bin\mysqld  --install3  4#  Remove the MySQL Windows service and execute this command at the terminal:  5"c:\mysql-5.7.16-winx64\bin\mysqld" --remove

After registering as a service, you only need to execute the following command when you start and close the MySQL service later:

1 # start the MySQL service 2 net start MySQL 3  4 # turn off MySQL service 5 net stop MySQL

Linux version

Installing MySQL with a binary package

Binary Package Name

Mysql-5.5.49-linux2.6-x8.6_64.tar.gz

Add Users and Groups

-s/sbin/nologin-g MySQL--1/etc/passwdid MySQL

Start installing MySQL

1[[email protected]]#mkdir-p/home/oldboy/tools2[[email protected]]#Cd/home/oldboy/tools3[[email protected] tools]#wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.49-linux2.6-x86_64.tar.gz4[[email protected] tools]#Tar XF mysql-5.5.49-linux2.6-x86_64.tar.gz5[[email protected] tools]#mkdir-p/application/6[[email protected] tools]#MV mysql-5.5.49-linux2.6-x86_64/application/mysql-5.5.497[[email protected] tools]#ln-s/application/mysql-5.5.49//application/mysql8[[email protected] tools]#ls-l/application/mysql9lrwxrwxrwx 1 root root 26 October 10:28/application/mysql-/application/mysql-5.5.49/Ten  One[[email protected] tools]#cd/application/mysql/ A[[email protected] MySQL]#ls-l support-files/*.cnf --rw-r--r--1 7161 wheel 4691 March 1 support-files/my-huge.cnf --rw-r--r--1 7161 wheel 19759 March 1 support-files/my-innodb-heavy-4g.cnf the-rw-r--r--1 7161 wheel 4665 March 1 support-files/my-large.cnf --rw-r--r--1 7161 wheel 4676 March 1 support-files/my-medium.cnf --rw-r--r--1 7161 wheel 2840 March 1 support-files/my-small.cnf -  + #copying my.cnf configuration Files -[[email protected] MySQL]#/BIN/CP support-files/my-small.cnf/etc/my.cnf +[[email protected] MySQL]#mkdir-p/application/mysql/data A[[email protected] MySQL]#chown-r mysql.mysql/application/mysql/
View Code

Initializing the database

1[[email protected] MySQL]#/application/mysql/scripts/mysql_install_db--basedir=/application/mysql--datadir=/application/mysql/data- -user=mysql2 Installing MySQL system tables ...3161027 10:30:22 [Note]/application/mysql/bin/mysqld (mysqld 5.5.49) starting as process 1958 ...4 OK5 Filling Help Tables ...6161027 10:30:23 [Note]/application/mysql/bin/mysqld (mysqld 5.5.49) starting as process 1965 ...7 OK8 9 To start mysqld at boot time with to copyTenSupport-files/mysql.server to the right place forYour system One  A REMEMBER to SET A PASSWORD for the MySQL root USER! - to does so, start the server, then issue the following commands: -  the/application/mysql/bin/mysqladmin-u Root Password'New-password' -/application/mysql/bin/mysqladmin-u root-h template.com Password'New-password' -  - Alternatively you can run: +/application/mysql/bin/mysql_secure_installation -  + which would also give you the option of removing the test ADatabases andAnonymous user created by default. This is atStrongly recommended forproduction servers. -  -See the manual forMore instructions. -  - You can start the MySQL daemon with: -Cd/application/mysql; /application/mysql/bin/mysqld_safe & in  -You can test the MySQL daemon with mysql-test-run.pl toCd/application/mysql/mysql-test; Perl mysql-test-run.pl +  -Problems at http://bugs.mysql.com/
View Code

Add a database file

1 [[email protected] MySQL]#  cp support-files/mysql.server  /etc/init.d/mysqld2 [[email protected] MySQL]#  chmod +x/etc/init.d/mysqld3 [[email protected] MySQL]# 4-rwxr-xr-x 1 root root 10880 Oct 10:31/etc/init.d/mysqld  

Binary default path is/usr/local/mysql the path inside the startup script is to be changed

1 [[email protected] MySQL]#  sed-i ' s#/usr/local/mysql#/application/mysql#g '/application /mysql/bin/mysqld_safe/etc/init.d/mysqld

Start the MySQL database

1 [[email protected] MySQL]#  /etc/init.d/mysqld start2

Check that the MySQL database is started

1 [[email protected] MySQL]#  netstat-lntup|grep mysql2 tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      2224/mysqld       

Set up MySQL boot from boot

1 [[email protected] MySQL]#  chkconfig--add mysqld2 [[email protected] MySQL]#  chkconfig mysqldon3 [[email protected] MySQL]#  chkconfig--listmysqld4< /c9> mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off

Configure boot-up

1 " #mysql Start by Huzhihua at 2016-10-27 " >>/etc/2"/etc/init.d/mysqld start" >>/etc/  34 [[email protected] MySQL]#5#  MySQL start by Huzhihua at 2016-10-276 /etc/init.d/mysqld start

Configure the global use path for MySQL commands

1 [[email protected] MySQL]#  echo ' export path=/application/mysql/bin: $PATH ' >>/etc/ profile2 [[email protected] MySQL]#  tail-1/etc/profile3 export path=/ application/mysql/Bin: $PATH4 [[email protected] MySQL]#  source/etc/profile 5 [[email protected] MySQL]#  echo $PATH6 /application/mysql/bin:/usr/ Local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

Log in to MySQL

Three ways to sign in:

1Mysql-uroot-p,2MySQL-Uroot3Mysql-uroot-p'oldboy123'4 5[[email protected] MySQL]#MySQL6Welcome to the MySQL Monitor. Commands End With;or\g.7Your MySQL Connection ID is18Server version:5.5.49MySQL Community Server (GPL)9 TenCopyright (c) +, Oracle and/orIts affiliates. All rights reserved. One  AOracle isA registered trademark of Oracle Corporation and/or its - affiliates. Other names trademarks of their respective - owners. the  -Type'Help ;' or '\h'  forHelp. Type'\c'To clear the current input statement. -  -Mysql> Exit #退出

Day1-mysql Installation Method Introduction

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.