Kill Thunder Dog---linux no:34 linux mysql installation and connection

Source: Internet
Author: User
Tags mysql client

MySQL can actually be installed through the Yum install Mysql-server, but considering many of the server's own bandwidth reasons, its practical is not particularly much, depends on the actual situation to decide ...

Of course, Yum installs the possible version will also be lower, if you want to install the new version of, in fact, can also be installed on their own, generic version.

The version we are using is 5.7.17

can also be downloaded through the mirror site of Sohu, as follows:

In the inside see so much direct search under mysql-5.7.17-linux so you can see as follows:

The red box above is the one we want to download ... If the system is 64-bit, choose the one below ...

Then copy the address and use wget under Linux to let him download it, as shown here:

After a long wait to finally download the good:

Then unzip her:

These two are just extracted.

Then we go to MySQL's official website to see how to install:


Installing MySQL on Unix/linux Using Generic Binaries Here is the generic binary version of Linux meaning, choose this can ...

Then here you can see his installation method, the online search out of a lot of methods are in accordance with this method of ....

It is obvious in the manual that we use MySQL to rely on the Libaio library ...

So we're going to install him first:

And after the decompression roughly see these several directories:

Then we unzip him out to study.

An introduction to the official manual installation is as follows:

Shell> GroupaddMySQL   #add a MySQL groupShell> Useradd-r-GMySQL-s/bin/false MySQL  #Add a user belonging to the MySQL group-s/bin/false MySQL means not to use the shell environment to prevent being attacked by othersShell> cd/usr/local#Enter the directory under/usr/localShell> Tar zxvf/path/to/MySQL-version-os.tar.gz#then unzipShell> ln-s full-path-to-MySQL-version-osMySQL   #reward a MySQL shortcutShell> CDMySQL  #to the top position just finished the amount will be, first: Reward a group and the user second: Unzip and then CD in ... Shell>mkdir MySQL-files#Create a directory named: Mysql-filesShell>chmod750MySQL-files#then change the mysql-files permissions toShell>Chown-RMySQL.#Change the current owner to MySQLShell>chgrp-RMySQL.#change all the groups to all MySQL groupsShell> bin/mysql_install_db--user=MySQL    #MySQL 5.7.5shell> bin/mysqld--initialize--user=MySQL #MySQL 5.7.6 and upShell> Bin/mysql_ssl_rsa_setup#MySQL 5.7.6 and upShell>Chown-R Root.Shell>Chown-RMySQLDataMySQL-Filesshell> Bin/mysqld_safe--user=MySQL&#Next command is optionalshell> CP support-files/MySQL. server/etc/init.d/MySQL.The server is broadly divided into: Add users first, CD to directory, then change the permissions and owner of the directory, initialize, initialize, and then change the owner of the directory, and finally start

Then we start to try ...

But we went missing a data directory:

Then we use the command mkdir data to create one for him, as follows:

Now our files are stored under/usr/local/src/mysql-5.7.17-linux-glibc2.5-i686, and then we follow the official manual requirements, move him to/usr/local/, and rename it to MySQL, his default name is long. 。。。。

MV MySQL-5.7.  - -Linux-GLIBC2. 5 - /usr/local/MySQL

Then go to the/usr/local/mysql directory:

Start playing according to the manual:

First, add a MySQL group:

Then create a MySQL user and add him to the MySQL group and have no access to the shell command:

Then create a directory named: mysql-files:

Then modify the permissions for Mysql-files 750:

Then modify the owner to change the owner of the current directory to all MySQL:

Then the group of the current directory is also changed to the MySQL group all ...

Then start initializing MySQL:

The carriage return appears as follows:

Dsxvnrdb4f+q This is a temporary password, the key is that each time the installation of the temporary password he generated is different ....

Because MySQL 5.7 was installed before the empty password, but after 5.7 he has generated a temporary password for us, so that every time must be saved this password otherwise it will be very depressed 、、、

Then you have to change the permissions again:

Then change the data directory and the Mysql-files directory to the MySQL user.

And then officially start the MySQL service ...

Then we'll check to see if he's started successfully:

Unfortunately, no success ...

That only choice, look at the log, look for problems, the address of the log in:/var/log/mysqld.log.

Then press the SPACEBAR to go to the next page.

Can't create ...

Then we go into the/var/run/mysqld/and see if there's a wooden file that has the mysqld.pid created.

Inside even mysqld This directory is Wood has ah ...

Wood has this directory, then we manually use a he created a not to be able to chant ....

But it is not enough, because this mysqld is used by the mysqld process.

This directory is owned by the root, so he has no right to operate, we want to transfer him can be.

Then check again to see that the permissions have been successfully transferred.

Then to start him again, if again wrong, then go to check the log ....

. /bin/--User=mysql &

And then the PS to see the next ...

But this is a success ...

Then we go to the bin directory to see.

We just started his mysqld. So we connect on the MySQL client to see.

One more mistake.

Not connected to the server via/temp/mysql.sock ...

Sock similar to a socket, the schematic is as follows:

The schematic diagram of the interaction between MySQL and mysqld, as shown above ...

We can see from the error message that the problem is very clear, because we color sock he deposited into the/var/lib/mysql/mysql.sock inside, and he went to/tmp/mysql.sock looking for.

In this case we can use the connection directly to solve the solution:

--------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------

Method 1:

/ var /lib/mysql//tmp/Mysql.sock

Then go ....

Although still not connected, but just now that the mistake has been solved. And the report is a password error, which proves that it is connected, and then we use the password to connect the test:

--------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------

Method 2:

We will just connect ln to kill, the equivalent of the server concession this step to kill.

Then we let the client make concessions, in order to test, we still carry on the test:

Another error, then we have to check the relevant help:

It is clear here that the client can go through the parameters to specify where he is going to look for the sock file.

. / - / var /lib/mysql/mysql.sock

and saw the Password:no ... This indicates that the connection is successful, but the password is wrong, then we can connect by the following methods:

This is OK, but this temporary password is too difficult to remember, can be modified by the following methods:

Alter User ' Root '@'localhost'by'root888';

The root888 here is the new code.

OK, Finish ...

Kill Thunder Dog---linux no:34 linux mysql installation and connection

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.