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

What are the ways to install mysql in Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Today, I will talk to you about the ways to install mysql in Linux, which may not be well understood by many people. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.

1. Yum installation

(1) first check whether the mysql that comes with centos is installed:

# yum list installed | grep mysql / / if you have your own installed mysql, uninstall it # yum-y remove mysql-libs.x86_64

(2) download the yum repository on MySQL's official website: https://dev.mysql.com/downloads/repo/yum/

# yum localinstall mysql57-community-release-el6-11.noarch.rpm// to check whether the yum repository has successfully added # yum repolist enabled | grep "mysql.*-community.*"

(3) when using the mysql yum repository, the latest version selected by default is installed, or you can select a version to install by manually editing the file. For example, to install the mysql5.6 version, set mysql56-community to set enabled=1,mysql57-community and set enabled=0.

# vim / etc/yum.repos.d/mysql-community.repo [mysql57-community] name=MySQL 5.7 Community Serverbaseurl= http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/enabled=0gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql# Enable to use MySQL 5.6 [mysql56-community] name=MySQL 5.6 Community Serverbaseurl= http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/enabled=1gpgcheck=1gpgkey=file:// / etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

(4) install mysql

# yum install mysql-community-server

(5) start the mysql service

# service mysqld start

If the following output appears, mysql is installed successfully:

Starting mysqld: [OK]

two。 Source code compilation and installation of mysql

(1) first install the packages required for source code compilation

# yum-y install make gcc-c++ cmake bison-devel ncurses-devel

(2) download and extract the installation package

# wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.14.tar.gz

# tar xvf mysql-5.6.14.tar.gz

(3) compilation and installation (compilation parameters are determined according to the actual situation)

# cd mysql-5.6.14# cmake.-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\-DMYSQL_DATADIR=/usr/local/mysql/data\-DSYSCONFDIR=/etc\-DWITH_MYISAM_STORAGE_ENGINE=1\-DWITH_INNOBASE_STORAGE_ENGINE=1\-DWITH_MEMORY_STORAGE_ENGINE=1\-DWITH_READLINE=1\-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock\-DMYSQL_TCP_PORT=3306\-DENABLED_LOCAL_INFILE=1\-DWITH_PARTITION_STORAGE_ENGINE=1\-DEXTRA_CHARSETS=all\ -DDEFAULT_CHARSET=utf8\-DDEFAULT_COLLATION=utf8_general_ci# make & & make install

(4) configure mysql

Set permissions:

# useradd mysql# passwd mysql# chown-R mysql:mysql / usr/local/mysql

Initialize mysql:

# cd / usr/local/mysql# scripts/mysql_install_db-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data-user=mysql

Note: there will be a my.cnf in the / etc directory, and you need to rename this file to another name, such as / etc/my.cnf.bak, otherwise, the file will interfere with the correct configuration of the MySQL installed by the source code, resulting in failure to start.

(5) Registration as a service

# cd / usr/local/mysql/support-files// Registration Service # cp mysql.server / etc/rc.d/init.d/mysql// use the default configuration file # cp my-default.cnf / etc/my.cnf// to boot up # chkconfig mysql on

(6) start the service

# service mysql start

3. Mysql client

This error usually occurs when you enter the mysql client for the first time:

Solutions are as follows:

(1) add the following command to / etc/my.cnf file:

(2) after restarting the mysql service, go to the mysql client and change the password of the root user:

Update mysql.user set authentication_string=password ("PASSWORD") where user= "root"; flush privileges

(3) comment out the command you just added and reset the password on the mysql client:

/ / set password strength and length > set global validate_password_policy=0; > set global validate_password_length=1;// change password > alter user 'root'@'localhost' identified by' PASSWORD'

(4) if you set root to be accessible remotely, you also need to execute:

> GRANT ALL PRIVILEGES ON *. * TO 'root'@'%' IDENTIFIED BY' PASSWORD' WITH GRANT OPTION; > flush privileges; after reading the above, do you have any further understanding of how to install mysql in Linux? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

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