Installation of MySQL on Windows and Linux

Source: Internet
Author: User
Tags mkdir mysql functions

MySQL-based multi-platform, multi-version installation

mysql.tar.gz Link: https://pan.baidu.com/s/1lG9BNL1mG4qbjM8xLHtrjQ Password: S4TK

MySQL is an open source small relational database management system, the developer of the Swedish MySQL AB company, the target
Formerly owned by Oracle, MySQL is widely used in small and medium-sized websites on the Internet. Because of its small size,
Fast, low total cost of ownership, especially the open source, many small and medium-sized web sites to reduce the overall
There is a cost to choose MySQL as the site database.

In response to the current mainstream LAMP architecture, MySQL is to get your IT operations, DBAs favor, currently MySQL
has been acquired by Orcacle, but the good news is that the original MySQL founder has independently developed a
MariaDB, and more and more people are using it. And MariaDB is compatible with all MySQL functions and related parameters.
The two main engines used by Mysql are MyISAM and InnoDB.

Linux:

There are many ways to install MySQL on Linux open-source platforms, and there are a number of common rpm,configure,cmake,yum (note that because of the version since 5.0 MySQL compiled installation CMake replaced configure, but also need make,make Install

Here are the main installation methods:

Method One: CMake compilation

Install CMake:

    1. Tar zxvf cmake-2.8.4.tar.gz
    2. CD cmake-2.8.4
    3. ./configure--prefix=/usr/local/cmake
    4. Make && make install

Installing mysql5.5.13

Groupadd MySQL //So here we're going to build a MSYQL user and group

    1. useradd-g MySQL mysql-s/usr/sbin/nologin
    2. Mkdir/usr/local/mysql //Create a directory
    3. Mkdir/usr/local/mysql/data

Into the mysql-5.5.13 directory:

Cmake-dcmake_install_prefix=/usr/local/mysql && make && make INSTALL

Enter MySQL under the installation directory/usr/local/mysql:

scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data--user=mysql//Initialize MySQL database

    1. CP support-files/my-medium.cnf/usr/local/mysql/my.cnf //copy configuration file
    2. Chown-r mysql:mysql/usr/local/mysql //Change Permissions

VI/USR/LOCAL/MYSQL/MY.CNF//Add the following content

[Mysqld]

Basedir =/usr/local/mysql

DataDir =/usr/local/mysql/data

Log-error =/usr/local/mysql/mysql_error.log

Pid-file =/usr/local/mysql/mysql.pid

user = MySQL

Tmpdir =/tmp

Start MySQL bin/mysqld_safe--user=mysql & or use the following command to add MySQL as a system service.

cd/usr/local/mysql/support-files/

    1. CP./mysql.server/etc/init.d/mysqld
    2. Service mysqld Start

Method Two: Yum package management

Since MySQL is not available in today's CentOS images, it is gradually replaced by mariadb, and there is no need to worry about the differences between MARIADB and MySQL, as the article begins.

Widows:

mysql-zip:https://dev.mysql.com/downloads/file/?id=476233

After the opening will go to another page, but did not start to download, this time do not fear, do not understand it is OK, you just know that he is to let you log in (login), or apply for account (sign up) on the line, login or successful application will start the download. (Remember the password to the combination of letters and numbers, letters should be uppercase)

Note: Passwords must be combined with letters and numbers, with uppercase letters

Of course, if you have an account, you can also log in directly

Click Downnow after success. File is not big, only 200 m, very soon, a little bit (after success is said to arrive below this place, but if you do not know this, you find it yourself, or directly quit, repeat the above steps, choose to login that just.

In many words, MySQL is open source database, so-called open source is able to view the source code, I believe that many children's boots will be interested in this. So where is the source code?

When I just entered-(the first picture that address). There is a select Platform, choose the following source code on the line.

(similarly if you want to download MySQL under the Linux platform is also here to find)

Download complete, proceed to install and configure

Second Step: Install (Unzip)

The ZIP version archive is free to install. Just unzip the line. It's no different from the installation version, but it doesn't need to be installed. Find the downloaded Mysql-x.x.xx-winx64.zip right-click to select (Unzip to ... ), find the place you want to install, like to put C: the choice of C: disk, do not like to choose one of their own, small parts like to put D: disk, after all, C: system disk put too much bad. After the decompression is OK, is it very simple? You know the benefits of the ZIP archive version?

Are you going to ask? How to use AH? The mysql inside the \ bin point. EXE how to come out a black window will not react?

No response because the service hasn't been opened yet!

No, it's not open, okay?

Service is not installed!

How to install?

Let's talk about it!

Step Three: Configure default files

In fact, in theory now it is possible to install the service directly, but because it is the default configuration, we use a lot of problems. For example, the Chinese characters are all garbled and so on, so it is recommended that you configure the default files first. In mysql-x.x.xx-winx64 (small part of the 5.6.17 according to their own version) under the directory, create a new My.ini. Copy the following code to save the OK. My.ini will replace the following My-default.ini file. ini file is a configuration file inside window. Save the various default data inside. The installation version of the installation is to let you choose your own and then the system to save you in, Zip archive is to write their own, all the same. What does the code syntax mean? Children's Shoes check the relevant information for themselves. After all, I can't say one or two words. This file is loaded while the software is running.

Code: (Change the inside D:\mysql\mysql-5.6.17-winx64 to your own software path, save)

Notepad edit My.ini

Step four: Install MySQL service

A start-up in the search bar inside the input cmd, the above will come out a cmd.exe, do not busy to determine, to right-click this cmd.exe select an administrator to run this option. Otherwise there will be an insufficient error code, the specific number of forgotten. This is a feature of Win7. You know, it's fine. If My.ini write wrong, the error code is 1067.

(You can also find this cmd.exe in the C:\Windows\System32 directory, also right-click it, as Administrator.) )

After you open the CMD window as an administrator, switch the directory to the bin directory where you unzipped the files, and my directory is the one in the picture, and your words should be in your own directory. Re-enter mysqld install enter run on the line, note is mysqld, not MySQL

A successful installation will be OK. I've already installed it, so that's the result.

This is followed by the input net start MySQL startup service. Or do not bother to manually, open the service manually started the MySQL service.

Tell us a simple way to Win7 open the service interface. Open Task Manager (right-click Task Manager or Ctrl+alt+delete, whatever you like). Click below the service is OK, is not very simple, than the control Panel that method is much simpler. Of course you can also enter services.msc in the CMD window is also possible.

Issues that may occur during the installation process:

1.d:\mysql-8.0.11-winx64\bin>net start MySQL

The MySQL service is starting.
The MySQL service could not be started.

The service did not report any errors.

Please type NET helpmsg 3534 for more help.

2. Further errors

D:\mysql-8.0.11-winx64\bin>mysqld--console
2018-07-18t13:21:30.946001z 0 [System] [MY-010116] [Server] D:\mysql-8.0.11-winx64\bin\mysqld.exe (mysqld 8.0.11) Starting as Process 11760
2018-07-18t13:21:30.983631z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory.
2018-07-18t13:21:30.986677z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2018-07-18t13:21:30.988397z 0 [ERROR] [MY-010119] [Server] aborting
2018-07-18t13:21:30.990846z 0 [System] [MY-010910] [Server] D:\mysql-8.0.11-winx64\bin\mysqld.exe:shutdown complete ( Mysqld 8.0.11) MySQL Community SERVER-GPL.

Solution:

1. Delete the data folder you created manually;

2. Admin rights cmd in the bin directory, remove the incorrectly installed MYSQLD service;

D:\mysql-8.0.11-winx64\bin>mysqld-remove MySQL
The service doesn ' t exist!

3. Execute mysqld--initialize-insecure in the bin directory of CMD

You will find that the program automatically creates the data folder and related files in the root directory of MySQL.

Execute Mysqld-install under 4.bin directory

Service successfully installed.

5.bin directory execution MySQL service startup net start MySQL
The MySQL service is starting:
The MySQL service has started successfully.


Implementation completed;

Step five: Open MySQL

Or do you want to switch the directory to D:\mysql\mysql-x.x.xx-winx64\bin (what X.XX.XXX is based on your own version) input mysql-uroot-p, default is no password. Enter into, of course, my password has been set, so you need to enter the password to go in. If you have a password, you can mysql-uroot-p the password, it can be mysql-uroot-p enter the password, recommend the second, the reason, you know after the hands.

How to set Password: mysqladmin-u root-p password password.

Exit the exit and you're done. Remember to directly close the CMD window is not exited, to enter exit will not exit AH.

Although MySQL is turned on, but every time you open MySQL to enter so many instructions to switch directories is not very annoying? How do you do that? Of course, I don't have to say, no, no hurry, I'll tell you.

Right-click My Computer, properties, advanced system settings, environment variable->path-> edit, put the full path of the bin directory under your MySQL software inside. I suggest that the children's shoes should be placed at the front, and finally the path to the directory is appended with an English semicolon (;) to save the line. such as D:\mysql\mysql-x.x.xx-winx64\bin;

Why do you do this? What's the principle? Simply saying that the path path inside the environment variable is the path to the CMD system's lookup directory. You enter a command, how does the system know that this command is there? What did the system do? In fact, the system is in the current directory and the system environment variable path inside the paths to find one side, find the first to prevail, can not find the error. So we either switch the cmd directory every time, or set up, and then do not need to switch the cmd path again.

An analogy: The system is like a bus. Follow the established route. The path inside the environment variable is the route or station. Get Off (run) when you get to the station (find the first one).

Now that we have the environment variables in place, let's run a little bit.

Cmd->mysql-uroot-p-Enter password->show databases; Find database->use database name; switch database directory->show tables; lookup table SQL query Work select * FROM table name->exit exit.

Other instructions are lost in the database operation, the small series will not repeat, you can find some related books.

Installation of MySQL on Windows and 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.