• notice
  • Congratulations on the launch of the Sought Tech site

Install MySQL tutorial in Linux system

Introduction

Now because of the needs of the project, I am building a Mysql cluster.Starting from the simplest, first install a Mysql under the Linux system.

Steps:

First Step: Installation:

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 system mysql combination mysql user:

Execute commands: groupaddmysql and useradd-r-g mysql mysql

Install the database:

Enter the directory where the mysql software is installed: execute the command cd/usr/local/mysql

Modify the owner of the current directory as the mysql user: execute the command chown-R mysql:mysql./

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

Modify the owner of the current directory as the root user: execute the command chown-R root:root./

Modify the owner of the current data directory as the mysql user: execute the command chown-R mysql:mysql data

The installation of this database is complete

Start the mysql service and add the boot mysql service:

Add boot startup: execute the command cpsupport-files/mysql.server/etc/init.d/mysql, and put the startup script in the boot initialization directory

Start mysql service: execute the command servicemysql start

Step 2: How to configure mysql:

Check whether our mysql has started successfully:

Enter: ps-ef | grep mysql

Modify the password of the root user of mysql, the initial password of root is empty:

Execute 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 starting the client, report:

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

Solution:

Question, I checked ours later,/etc/my.cnf:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
 
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Solution:

socket is in the/var/lib/mysql/mysql.sock path.At this time, we need to link such as mysql.sock to tmp/mysql.sock.

Note: Actually, this problem is very obvious.Everyone, look at the Socket parameters, which are in/var/lib/mysql/mysql.sock, and the address for the tcp protocol is tmp/mysql.sock, so we need to Otherwise, the sockket=/tmp/mysql.sock on the sauce.Of course we all know that, in fact, we only need to connect to the tmp/mysql.sock softly.

The method we adopted:

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

In this way, in fact, all our logins to mysql are logged in the user table in the mysql library in mysql.When we connect to windows in this table, it is like this'user@host' , For a simple example, if the ip of my computer is '192.168.22.28', then the connection I send out is like this'[email protected]', so, therefore, when we modify, the host is '%' represents all connected clients.At this time, we only need to modify the password.

However, when I was connected in my Navicat, I found that it could not be connected, so I will check to see if the password is wrong.Let’s check the user table again:

We can see that the password we modified above is localhost to '123456' (here are all encrypted with MD5), but we use'%'.At this time, we found that the two passwords are different, this At that time, we need to check what the password is.Of course, I guessed it.It should be root.Therefore, I set the link password of Navicat to'root' and found that it can be connected...

You may also have this problem:

This is how telnet connects to mysql.There is a problem of garbled characters and h_mysql_native_passowrd.At this time, just leave it alone.There is no impact.

Conclusion:

When we are doing something, we need to think and learn at the same time in order to make the efficiency faster!

Tags

Technical otaku

Sought technology together

Related Topic

0 Comments

Leave a Reply

+