Get the App
SLTechnology News&Howtos  ›  Database  › 

Binary compiler-free installation of mysql under Linux

Shulou Source: shulou.com Published: 2022-06-01 12:10:39 10月24日 Update

1. Download mysql to / usr/local/src/

Cd / usr/local/src/wget http://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz

2. Decompression

[root@server1 src] # tar-zxvf/usr/local/src/mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz

3. Establish mysql users

[root@server1 src] # groupadd mysql [root@server1 src] # useradd-g mysql-s/sbin/nologin-M mysql [root@server1 src] # id mysqluid=500 (mysql) gid=500 (mysql) groups=500 (mysql)

4. Move the decompressed data to / usr/local/mysql

[root@server1 src] # mv mysql-5.6.30-linux-glibc2.5-x86_64 / usr/local/mysql

The bin directory contains client tools and mysqld

Data directory stores database data files and log files

The docs directory contains user manuals in info format

The include directory contains mysql header files

The lib directory contains related lib libraries

The mysql-test directory contains some test script files for mysql

The scripts directory stores mysql_install_db initialization files

The share directory stores a variety of support files, including error messages, language coding support, sql installation scripts, and so on.

The Sqlbench directory stores benchmark scripts

The support-file directory stores the mysql configuration file template

5. Create a directory where the database is stored, and authorize

[root@server1 mysql] # mkdir-p / data/mysql [root@server1 mysql] # chown-R mysql.mysql / data/mysql/ [root@server1 mysql] # chown-R mysql.mysql / usr/local/mysql/. / / Database installation path

6. Copy the mysql configuration file to / etc/my.cnf

[root@server1 mysql] # rm-f / etc/my.cnf [root@server1 mysql] # cd support-files/ [root@server1 support-files] # lsbinary-configure magic mysqld_multi.server mysql-log-rotate mysql.server [root@server1 support-files] # cp / usr/local/mysql/support-files//etc/my.cnf

Edit the / etc/my.cnf configuration file and add the following lines

User = mysql/ / user basedir = / usr/local/mysql / / basic directory datadir = / data/mysql/ / database save directory port = 3306 / / database port socket = / data/mysql/mysql_3306.sock log-error = / data/mysql/mysql_error.log / / database error date Log file pid-file = / data/mysql/mysql.pid / / Database process occupies PID # memory usage limit performance_schema_max_table_instances=400 table_definition_cache=400 table_open_cache=256

7. Initialize the database

[root@server2 mysql] # / usr/local/mysql/scripts/mysql_install_db-user=mysql-datadir=/data/mysql/ [root@server2 mysql] # echo $? 0

A common problem with initializing the database: the system version is inconsistent with the database version, resulting in an error in initializing the database.

8. Copy the mysql startup script to / etc/init.d/mysqld

[root@server1 support-files] # cp / usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld [root@server1 support-files] # chmod + x/etc/init.d/mysqld

9. Join the boot self-startup mysql service

[root@server1 mysql] # chmod + x/etc/init.d/mysqld [root@server1 mysql] # chkconfig-- addmysqld [root@server1 mysql] # chkconfig-level 35 mysqldon

10. Start the mysql service

[root@server1 mysql] # / etc/init.d/mysqldstartStarting MySQL. []

11. After the msyql service is started, check / data/mysql some more files

[root@server1 mysql] # ls / data/mysql/auto.cnf ib_logfile0 mysql mysql_error.log performance_schemaibdata1 ib_logfile1 mysql_3306.sock mysql.pid test [root@server1 mysql] # netstat-lnapt | grepmysqld tcp 0 0: 3306:: * LISTEN 3195/mysqld

12. Add environment variables

[root@server1 ~] # vim/etc/profile.d/mysql.sh

#! / bin/bashexportPATH= "$PATH:/usr/local/mysql/bin"

[root@server1 ~] # source/etc/profile.d/mysql.sh

13. The newly added mysql does not set the root password. You can use the following command to set the root password:

# / usr/local/mysql/bin/mysqladmin-S / data/mysql/mysql_3306.sock-u root password' new-password'

14. Log in to mysql

[root@server2 ~] # mysql

ERROR 2002 (HY000): Can'tconnect to local MySQL server through socket'/ tmp/mysql.sock' (2)

Problem: no mysql.sock was found in the / tmp directory. There are three solutions:

1) soft link / data/mysql/mysql_3306.sock to / tmp/mysql.sock

Ln-s / data/mysql/mysql_3306.sock/tmp/mysql.sock

2) modify / etc/my.cnf to add the following lines

[client]

Socket = / data/mysql/mysql_3306.sock

3) execute the following command to specify the socket connection file, mysql-S / data/mysql/mysql_3306.sock

[root@server1 ~] # mysql-S/data/mysql/mysql_3306.sock

Tags: Directories data files databases scripts users services configurations commands passwords logs versions errors problems support consistency information memory methods variables Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MySQL OPPO Reno vpn Shulou Information