Get the App
SLTechnology News&Howtos  ›  Database  › 

MySQL source code compilation and installation

Shulou Source: shulou.com Published: 2022-06-01 12:14:05 09月14日 Update

1. Install cmake-2.8.10.2.tar.gz

Enter shell as root user

# tar-zxvf cmake-2.8.10.2.tar.gz

# cd cmake-2.8.10.2

#. / configure

# make (cannot make, detect gcc compilation environment)

# make install

-

2. Install ncurses-5.9.tar.gz

# tar-zxvf ncurses-5.9.tar.gz

# cd ncurses-5.9

# mkdir / usr/local/ncurses-5.9/

#. / configure-prefix=/usr/local/ncurses-5.9/

# make

# make install

-

3. Install mysql-5.5.28.tar.gz

# tar-zxvf mysql-5.5.28.tar.gz

# cd mysql-5.5.28

# mkdir-p / usr/local/mysql (create database installation directory)

# mkdir-p / usr/local/mysql/data (storing database)

# groupadd mysql

# useradd-r-g mysql mysql

Start compiling mysql source code

# cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/-DMYSQL_DATADIR=/usr/local/mysql/data-DCURSES_INCLUDE_PATH=/usr/local/ncurses-5.9/include/-DCURSES_LIBRARY=/usr/local/ncurses-5.9/lib/libncurses.a

# make

# make install (mysql will be installed after this one is finished)

4. Configure MySQL

Set directory permissions

# cd / usr/local/mysql

# chown-R root:mysql. (set the owner owner of all files in the current directory to root and the group to which they belong to mysql)

# chown-R mysql:mysql data

# cp support-files/my-medium.cnf / etc/my.cnf (add mysql startup service to system service)

Create a table for the system database

# cd / usr/local/mysql

# scripts/mysql_install_db-user=mysql

Start mysql manually

# cd / usr/local/mysql

#. / bin/mysqld_safe-user=mysql &

# mysqladmin-u root-p shutdown (stop the MySQL service, where the root user of MySQL has not yet configured a password, so it is null. When you need to enter a password, just click the enter key.)

Another simple way to start mysql (mysql has been added to the system service)

# cp support-files/mysql.server / etc/init.d/mysql (add mysql startup service to system service)

# service mysql.server start starts mysql service

# service mysql.server stop shuts down mysql service

# service mysql.server restart restart mysql service

Add mysql to the environment variable so that you can enter mysql by typing mysql in the shell environment.

# vi / etc/profile

Join at the end

Export MYSQL_HOME=/usr/local/mysql

Export PATH=$MYSQL_HOME/bin:$PATH

# wq save

# source / etc/profile refresh configuration file

After typing in mysql, you can see the mysql console interface.

Change the password of the root user of MySQL and open a remote connection

# mysql-u root mysql

Mysql > use mysql

Mysql > desc user

Mysql > GRANT ALL PRIVILEGES ON *. * TO root@ "%" IDENTIFIED BY "root"; (the ability to add remote connections to root.)

Mysql > update user set Password = password ('root') where User='root'; (set root user password to root, customizable)

Mysql > select Host,User,Password from user where User='root'

Mysql > flush privileges

Mysql > exit

Log in again: mysql-u root-proot

If a remote connection cannot be made, turn off the firewall

# / etc/rc.d/init.d/iptables stop

Tags: Service password user system data database environment directory configuration compilation owner file source code variable enter key finished ownership manual console method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Tech Info macOS NVidia MySQL