Here are two ways to install MySQL under Linux: yum installation and source code compilation installation. 1. Yum installation (1) First check whether the MySQL that comes with centos is installed: # yum list installed |grep mysql //If there is a pre-installed mysql, uninstall it# yum -y remove mysql-libs.x86_64 (2) Download the yum repository from the MySQL official website: https://dev.mysql.com/downloads/repo/yum/, # yum localinstall mysql57-community-release-el6-11.noarch.rpm // Check if the yum repository is added successfully # yum repolist enabled |grep "mysql.*-community.*" (3) When using the MySQL yum repository, the latest version is selected for installation by default. You can also select a version to install by manually editing the file. For example, to install MySQL version 5.6, set enabled=1 in mysql56-community and enabled=0 in mysql57-community. # vim /etc/yum.repos.d/mysql-community.repo [mysql57-community] name=MySQL 5.7 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Enable to use MySQL 5.6 [mysql56-community] name=MySQL 5.6 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=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 ] 2. Compile and install MySQL from source code (1) First install the packages required for source code compilation # yum -y install make gcc-c++ cmake bison-devel ncurses-devel (2) Download and decompress the installation package # wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.14.tar.gz (3) Compile and install (compile parameters are determined according to actual conditions) # 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 file in the /etc directory. 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 MySQL installed from source code and cause it to fail to start. (5) Register 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 //Set up startup# chkconfig mysql on (6) Start the service # service mysql start 3. mysql client When you first enter the mysql client, this error usually occurs: The solution is as follows: (1) Add the following command to the /etc/my.cnf file: (2) After restarting the MySQL service, enter the MySQL client and change the root user's password: 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 in 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 the root user to have remote access, you also need to execute: > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION; > flush privileges; Then you can create databases, tables, etc. through the mysql client. Summarize You may also be interested in:
|
<<: Example of how to import nginx logs into elasticsearch
>>: JS thoroughly understands GMT and UTC time zones
There are few and inadequate installation tutoria...
Preface echarts is my most commonly used charting...
As shown below: LOCATE(substr,str) Returns the fi...
Since this is my first post, if there are any mis...
A vector wave <svg viewBox="0 0 560 20&qu...
This article example shares the specific code of ...
Method 1: var a = [1,2,3]; var b=[4,5] a = a.conc...
In Linux systems, especially server systems, it i...
Table of contents Registering Components Adding C...
MJML is a modern email tool that enables develope...
The logs in MySQL include: error log, binary log,...
Docker version 1.13.1 Problem Process A MySQL con...
In Linux system, both chmod and chown commands ca...
The installation process is basically the same as...