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

RedHat 6.7 install Mysql 5.7.18

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

Share

Shulou(Shulou.com)06/01 Report--

Environmental preparation:

Operating system: RedHat 6.7

Database: Mysql 5.7.18

1. Download mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz from the official website

Official website address: http://dev.mysql.com/downloads/mysql/

two。 Create user groups / users, data directories and their user directories for mysql

Mkdir / home/mysql

Mkdir / mysql_data

Groupadd-g 505 mysql

Useradd-u 506-g mysql-s / bin/false-d / home/mysql mysql

3. Extract the installation package and copy the contents of the package to the mysql installation directory / home/mysql

Tar-xvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz-C / home/mysql/

Cd / home/mysql

Mv mysql-5.7.18-linux-glibc2.5-x86_64 mysql

Cd mysql

Mv *.. /

Chown mysql:mysql-R / home/mysql

Chown mysql:mysql-R / mysql_data

Chmod 750R / home/mysql

Chmod 750R / home/mysql_data

4. Initialize the database

Vim mysql.server

Modify the basedir and datadir in the startup script to the directory we specified

Basedir=/home/mysql

Datadir=/mysql_data

[root@iccsdb02 mysql] # / bin/mysqld-- user=mysql-- basedir=/home/mysql-- datadir=/mysql_data-- initialize

2017-04-26T02:17:42.485369Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use-explicit_defaults_for_timestamp server option (see documentation for more details).

2017-04-26T02:17:43.083466Z 0 [Warning] InnoDB: New log files created, LSN=45790

2017-04-26T02:17:43.236539Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2017-04-26T02:17:43.357511Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 87cd07e3-2a26-11e7-afe5-0800275a2175.

2017-04-26T02:17:43.385762Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

2017-04-26T02:17:43.387836Z 1 [Note] A temporary password is generated for root@localhost: 9NuZjvE > fsZb

After switching to mysqld-- initialize, if there is already a data file in the target directory pointed to by datadir, the warning error will appear as follows:

Delete and reinitialize after emptying

2017-04-24T08:51:45.724122Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use-explicit_defaults_for_timestamp server option (see documentation for more details).

2017-04-24T08:51:45.727068Z 0 [ERROR]-- initialize specified but the data directory has files in it. Aborting.

2017-04-24T08:51:45.727113Z 0 [ERROR] Aborting

5. Check if the mysql service can be started

# cd / home/mysql/support-files

[root@iccsdb02 support-files] #. / mysql.server start

Starting MySQL.Logging to'/ mysql_data/iccsdb02.err'.

[OK]

If an error occurs as follows:

Starting MySQL.2017-04-25T03:03:32.124076Z mysqld_safe Directory'/ var/lib/mysql' for UNIX socket file don't exists.

The server quit without updating PID file (/ var/lib/mysql/i [failed] 1.pid).

Check the / etc/my.cnf file to see if datadir and so on are correct. There is no such configuration file by default. We may need to add it manually later.

6. Create a soft link

Ln-s / home/mysql/bin/mysql / usr/bin/mysql

Ln-s / home/mysql/bin/mysqladmin / usr/bin/mysqladmin

7. Configure mysql service boot to start automatically

Copy the startup file to / etc/init.d/ and repeat the command as mysqld

# cp / home/mysql/support-files/mysql.server / etc/init.d/mysqld

Increase the executive authority

# chmod 755 / etc/init.d/mysqld

Check that there is no mysqld in the list of self-launch items, and if not, add mysqld:

# chkconfig-list mysqld

# chkconfig-add mysqld

Set MySQL to start automatically at level 345

# chkconfig-- level 35 mysqld on

8. Start / restart / stop the mysql service. In fact, mysql should be able to start normally at this point.

Start the mysql service

# service mysqld start

Stop the mysql service

# service mysqld stop

Restart the mysql service

# service mysqld restart

9. Create a profile

Default my.cnf backup, if any

# mv / etc/my.cnf / etc/my.cnf.bak

Enter the mysql installation directory to support the file directory

# cd / home/mysql/support-files

# cp my-default.cnf / etc/my.cnf this step does not see the corresponding my-default.cnf file in this version of the software

You can modify the new configuration file options as needed, without modifying the configuration options, and mysql runs according to the default configuration parameters.

The default / etc/my.cnf is not available. You can create one yourself or download one from the Internet. Here, set the code to utf8 to prevent garbled code. The configuration file I tested is as follows:

[mysqld]

Datadir=/my_data

Socket=/var/lib/mysql/mysql.sock

User=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks

Symbolic-links=0

Character_set_server=utf8

Init_connect='SET NAMES utf8'

[mysqld_safe]

Log-error=/var/log/mysqld.log

Pid-file=/var/run/mysqld/mysqld.pid

[client]

Default-character-set=utf8

10. There are many ways to initialize the password of the mysql user root on the Internet, but it is easy to use after testing, so I just follow this one.

Modify the configuration file of MySQL (default is / etc/my.cnf) and add a line skip-grant-tables under [mysqld]

After service mysqld restart, you can directly use mysql to enter

[root@iccsdb02 run] # mysql

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 3

Server version: 5.7.18 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

Mysql >

Mysql > update mysql.user set authentication_string=password ('1q2w3e') where user='root' and Host =' localhost'

Query OK, 1 row affected, 1 warning (0.12 sec)

Rows matched: 1 Changed: 1 Warnings: 1

Mysql > flush privileges

Query OK, 0 rows affected (0.03 sec)

Mysql > quit

Entering again will also prompt you to change your password.

Root@iccsdb02 run] # mysql-u root-p

Enter password:

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 4

Server version: 5.7.18

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

Mysql > show databases

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

Mysql >

Just update the password.

[root@iccsdb02 mysql] # mysqladmin-u root-p password

Enter password:

New password:

Confirm new password:

Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

[root@iccsdb02 mysql] #

[root@iccsdb02 mysql] # mysql-u root-p

Enter password:

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 7

Server version: 5.7.18 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

Mysql > show databases

+-+

| | Database |

+-+

| | information_schema |

| | mysql |

| | performance_schema |

| | sys |

+-+

4 rows in set (0.00 sec)

Mysql >

All right, mysql 5.7.18 has been successfully installed and can be accessed and used locally.

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