Installing Mysql in Linux tutorial _ MySQL

Source: Internet
Author: User
This article will share with you how to install the mysql graphic tutorial in linux. The step is very detailed and practical. we recommend it to you here. Introduction

Now, because the project needs to build a Mysql Cluster, first install a Mysql in linux from the simplest start.

Steps:

Step 1: Install:

Tarmysql-5.5.48-linux2.-x86_64.tar.gz

Copy to the specified path:

Cpmysql-5.5.48-linux2.6-x86_64/usr/local/mysql-r.

Add mysql users in the system:

Run the following commands: groupaddmysql and useradd-r-g mysql.

Install the database:

Go to the mysql installation directory and run the command cd/usr/local/mysql.

Modify the current directory owner to a mysql User: execute the command chown-R mysql: mysql ./

Install the database: execute the command./scripts/mysql_install_db -- user = mysql

Run chown-R root: root ./

Modify the current data directory owner to a mysql User: execute the command chown-R mysql: mysql data

The database has been installed.

Start mysql service and add boot start mysql service:

Add boot start: run the command cpsupport-files/mysql. server/etc/init. d/mysql to put the startup script to the boot initialization directory.

Start mysql service: run servicemysql start

Step 2: Configure mysql:

Check whether mysql is successfully started:

Input: ps-ef | grep mysql

Modify the root user password of mysql. if the initial root password is empty:

Run the command:./bin/mysqladmin-u root-h localhost. localdomain password 'password'

Put the mysql client in the default path:

Ln-s/usr/local/mysql/bin/mysql/usr/local/bin/mysql

Note:

When the client is started, the following message is displayed:

Can't connect tolocal MySQL server through socket '/tmp/mysql. sock' (2)

Solution:

Then, I checked our,/etc/my. cnf:

[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0 [mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid

Solution:

The socket is in the/var/lib/mysql. sock path. at this time, we need to link mysql. sock to tmp/mysql. sock.

Note: In fact, this problem is very obvious. you can refer to the Socket parameters in/var/lib/mysql. in sock, and the tcp address is tmp/mysql. sock, so we will also paste the sockket =/tmp/mysql above. sock. Of course, we all know that we only need to connect to tmp/mysql. sock.

Our method:

In addition, we solve the problem that windows cannot connect to mysql in linux:

In this way, all our login to mysql is logged on to the user table in the mysql database in mysql. when we connect to windows in this table, A simple example is that if the ip address of my computer is '123. 168.22.28 ', the connection I sent is like 'root @ 192.168.22.28'. Therefore, when we modify the host, the host is '% ', represents all the connected clients. at this time, we only need to modify the password.

However, when I connect to my Navicat and find that it cannot be connected, I will check to see if the password is incorrect. let's check the user table again:

We can see that the above password is changed to localhost to '123' (MD5 encryption is used here), but we use '%'. at this time, the two passwords are different. at this time, we need to check what the password is. of course, I guess it should be root. therefore, I set navicat's link password to 'root' and found the link can be connected...

You may also have the following problems:

In this case, when connecting to mysql via telnet, the problem of garbled characters and h_mysql_native_passowrd may occur. in this case, you can leave it alone. There is no impact.

Conclusion:

When we are doing something, we need to think and learn to make efficiency faster!

The above is the installation of Mysql tutorial _ MySQL in Linux. For more information, see PHP Chinese network (www.php1.cn )!

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.