Get the App
SLTechnology News&Howtos  ›  Database  › 

Steps to install MySQL5.6.39 on CentOS6.5

Shulou Source: shulou.com Published: 2022-06-01 06:37:31 11月22日 Update

1. Extract the installation file

1.1 decompression

Tar-zxvf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz

Rename mysql-5.6.39-linux-glibc2.12-x86_64 to mysql

Mv mysql-5.6.39-linux-glibc2.12-x86_64 mysql

1.3 copy the extracted mysql directory

Mv mysql / usr/local/

two。 Add users and user groups

2.1 add user Group

Groupadd mysql

2.2 add user mysql to user group mysql

Useradd-g mysql mysql

3. Installation

3.1 change directory to / usr/local/mysql/

[root@hadoop01 ~] # cd / usr/local/mysql/

3.2 create a data folder

[root@hadoop01 mysql] # mkdir. / data/mysql

3.3 modify file permissions

[root@hadoop01 mysql] # chown-R mysql:mysql. /

3.4 install and specify the user and data folder location

[root@hadoop01 mysql] # / scripts/mysql_install_db-- user=mysql-- datadir=/usr/local/mysql/data/mysql

3.5 copy mysql into the service auto-startup

[root@hadoop01 mysql] # cp support-files/mysql.server / etc/init.d/mysqld

3.6 modify the permission to 755, that is, root can execute

[root@hadoop01 mysql] # chmod 755 / etc/init.d/mysqld

3.7 copy the configuration file to etc, because the default startup is to load the configuration file under etc first.

[root@hadoop01 mysql] # cp support-files/my-default.cnf / etc/my.cnf

3.8 modify startup script

[root@hadoop01 mysql] # vi / etc/init.d/mysqld

3.9 modifications:

Basedir=/usr/local/mysql/

Datadir=/usr/local/mysql/data/mysql

3.10 set the server-side coding of msyql database

[root@hadoop01 mysql] # vi / etc/my.cnf

# add an item under [mysqld]: (note: only adding character-set-server=utf8 project code does not work, you need to add init-connect='SET NAMES utf8' item at the same time to take effect)

Character-set-server=utf8

Init-connect='SET NAMES utf8'

MySQL under # Linux is case-sensitive by default. You can make MySQL not case-sensitive by setting it as follows. In Windows, this option is 1.

Lower_case_table_names=1

3.11 add the environment variable and edit / etc/profile so you can use the mysql command anywhere

[root@hadoop01 mysql] # vi / etc/profile

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

# for the changes to take effect immediately, you need to execute the following code

[root@hadoop01 mysql] # source / etc/profile

3.12 start the service

# start mysql

# service mysqld start

# turn off mysql

# service mysqld stop

# restart mysql

# service mysqld restart

# check the running status

# service mysqld status

[root@hadoop01 mysql] # service mysqld start

3.13 when the test connection mysql was installed for the first time, no password was set for root, so you can log in directly.

[root@hadoop01] # mysql-u root

3.14. Set root password

Mysql > UPDATE user SET password=PASSWORD ('newpassword') where USER='root'

Mysql > GRANT ALL PRIVILEGES ON *. * TO 'root'@'%' IDENTIFIED BY' newpassword' WITH GRANT OPTION; # set remote ip connectable

Mysql > FLUSH PRIVILEGES; # remember this sentence, otherwise if you close the previous terminal, the original error will occur again.

Tags: Files users user groups services size passwords data folders permissions directories coding configuration that is code location functions variables at the same time commands places Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Technology Huawei Microsoft NVidia