Install MySQL under CentOS6.8

        1. Download

        Log in to the mysql official website download page: https://dev.mysql.com/downloads/ , select the Linux system source version to download.

 

        2. Old version

        Enter the system and use the following command to check whether mysql is installed in the system:

rpm -qa | grep mysql

        If the returned result contains mysql or related components, you can use the rpm -e command to uninstall.

rpm -e xxxxx //Normal uninstall mode
rpm -e --nodeps xxxxx // Forced uninstall mode, which ignores associated component prompts

 

        3. Installation

        1) Install the components needed to compile the code

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

        2) Unzip mysql

       Upload mysql to the /usr/local/software directory

chmod +x mysql-boost-5.7.18.tar.gz

        Unzip the installation package

tar -zxvf mysql-boost-5.7.18.tar.gz

        3) Create mysql user

groupadd mysql
useradd -r -g mysql -s /bin/false mysql

        4) Compile

cd mysql-5.7.18
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 \
-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 \
-DWITH_BOOST=/usr/local/boost

        Execute after finishing:

make&make install

        5) Initialize the database

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

        6) Configure mysql

vi /etc/profile

        Add to the file:

PATH=/usr/local/mysql/bin:$PATH
export PATH

        Then execute:

source /etc/profile

        Finally, copy the mysql startup script and start mysql

cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
service mysql start

        This will randomly start mysql.

        7) Configure users

        Initialize user password

mysql -uroot
SET PASSWORD = PASSWORD('123456');

        Configure access rights

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '654321' WITH GRANT OPTION;

        The password for accessing the external address of the root user can be different from the local one, or it can be configured as another user.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326321756&siteId=291194637