Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and configure Mysql for Linux with source code

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how to install and configure Mysql for Linux with source code". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Installation

-- assume that there are already two source code compressed files, mysql-5.5.10.tar.gz and cmake-2.8.4.tar.gz.

1) install cmake first (mysql5.5 is later compiled through cmake)

# tar-zxv-f cmake-2.8.4.tar.gz

# cd cmake-2.8.4

#. / configure

# make

# make install

2) create mysql installation directory and data directory

# mkdir-p / usr/local/mysql-- mysql installation directory

# mkdir-p / usr/local/mysql/data-- mysql data directory

3) create mysql users and user groups

# groupadd mysql

# useradd-r-g mysql mysql

4) install mysql

# tar-zxv-f mysql-5.5.10.tar.gz

# cd mysql-5.5.10

# cmake.

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql

-DMYSQL_DATADIR=/usr/local/mysql/data

-DDEFAULT_CHARSET=utf8

-DDEFAULT_COLLATION=utf8_general_ci

-DEXTRA_CHARSETS=all

-DENABLED_LOCAL_INFILE=1

Note:

Parameters in the above command:

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-- installation directory

-DINSTALL_DATADIR=/usr/local/mysql/data-- Database storage directory

-DDEFAULT_CHARSET=utf8-- use utf8 characters

-DDEFAULT_COLLATION=utf8_general_ci-- check character

-DEXTRA_CHARSETS=all-- install all extended character sets

-DENABLED_LOCAL_INFILE=1-- allows data to be imported locally

# make

# make install

Note:

When recompiling, you need to clear the old object files and cache information.

# make clean

# rm-f CMakeCache.txt

# rm-rf / etc/my.cnf

two。 Configuration and management

1) set directory permissions

# cd / usr/local/mysql

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

# chown-R mysql:mysql data

2) copy the mysql parameter file

# cp support-files/my-medium.cnf / etc/my.cnf

3) initialize the database (create a system database)

# cd / usr/local/mysql

# scripts/mysql_install_db-user=mysql

4) set environment variables

# vi / root/.bash_profile

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib

# source / root/.bash_profile

5) manually start and shut down mysql

-- start mysql

# cd / usr/local/mysql

#. / bin/mysqld_safe-- user=mysql &-- start mysql, but you cannot stop mysql with this command. The startup log is written in this file: / usr/local/mysql/data/localhost.err

-- shut down the MySQL service

# mysqladmin-u root-p shutdown-at this time, the mysql root user has not set a password, so it is empty. When entering the password, just click the enter key.

6) start and shut down mysql through the service (provided that mysql has been added to the system service)

# service mysql.server start

# service mysql.server stop

# service mysql.server restart

-- if the service information not recognized by mysql.server appears when running the above command, it may be caused by the fact that mysql is not added to the system service, which can be added as follows.

# cp support-files/mysql.server / etc/init.d/mysql-copy mysql.server to the system service directory / etc/init.d and name it mysql

# chkconfig-add mysql

# chkconfig-list

-- set the mysql service to start automatically at levels 3 and 5

# chkconfig-- level 35 mysql on

-- set the mysql service to start automatically at levels 2, 3, 4 and 5

# chkconfig mysql on

Note:

On some systems, mysql.server is in the / usr/local/mysql/share/mysql/ directory, not the / usr/local/mysql/support-files/ directory in this article.

7) modify mysql user's root password and enable remote connection authorization

# mysql-u root mysql

Mysql > use mysql

Mysql > desc user

Mysql > GRANT ALL PRIVILEGES ON *. * TO root@ "%" IDENTIFIED BY "root";-- enable user root remote connection permissions

Or

Mysql > GRANT ALL PRIVILEGES ON *. * TO 'root'@'%' IDENTIFIED BY' * 'WITH GRANT OPTION;-if remote connection cannot be made and error mysql error number 1130 is reported

Mysql > update user set Password = password ('xxxxxx') where User='root';-- change the user's root password

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

Mysql > flush privileges

Mysql > exit

Note:

If you cannot make a remote connection, you can try to turn off the firewall with the following command.

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

This is the end of the content of "how to install and configure Mysql for Linux with source code". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report